Collaborative post

Critical Commands and Initial Setup Processes with Docker

0
33

Docker is a very intuitive platform. However, you need to know what commands and processes to use.

There are a lot of great commands and Docker registries that you need to learn. It is important to do your due diligence and master them effectively.

You will find Docker is much easier to learn than Java after you get started. The following overview should simplify things.

Laptop
Photo by Glenn Carstens-Peters on Unsplash

Determining if Your Docker Works

To test if Docker works properly, we can use the command docker run. The syntax of the “run” command looks like this:

docker run <Image Name>

This command will execute commands within a Docker container. The option <Image Name> is pretty self-explanatory. It denotes the name of the image (e.g. hello-world, apache, nginx) which should be started and executed as a container. This is great for rapid application development.

Your first container prints “Hello World.”

Now execute the following command in your command line:

docker run hello-world

When you execute this command, the image “hello-world” is downloaded. After the download, the image is executed as a container.

You will receive a confirmation that the installation was successful. You also get the text “Hello from Docker!”, along with other options and command examples.

At this point, you have just started your first container with the image “hello-world”.

This quickly raises the following question:

What other images exist besides the one that outputs “hello-world”? This question is answered by the so-called “Docker Hub”.

Understanding Docker Hub – The directory for images

The Docker Hub is a directory that lists all available community images that are available for download. You can also upload your own Docker images and share them with others.

Here are some of the most popular Images from the Docker Hub:

  • Apache
  • Nginx
  • MySQL
  • Ubuntu
  • Centos
  • Debian
  • Node
  • Mariadb
  • Alpine

You can download base images for your Docker Containers from the Docker Hub. But what exactly is an image and what can you do with it?

Docker Images – What can you do with them?

Images play a central role in the Docker interface. They are used for containerization and other essential processes.

The Docker command is specific and tells the Docker program on the operating system that something needs to be done.

The run command mentions that we want to create an instance (container) of an image

Finally, “nginx” represents the image from which the container is executed.

Now, let’s look at how we can use the nginx image available in the Docker Hub to run the nginx web server on our computer. We can do this by running the following command on the command line:

Show Docker Images

To display the image list on your system, you should use the “docker images” command:

docker images

This command displays all images that have been installed.

From the output, you can tell that the server (more precisely my local Windows machine) has two images installed:

  • Nginx
  • Hello World

These attributes apply to every image:

  • TAG – This command delimits or tags images.
  • IMAGE-ID – This ID identifies the image.
  • CREATED – This command specifies the age of the image (in days).
  • SIZE – This command specifies the image size.

The rmi command can remove Docker images. Let’s take a closer look at this command:

docker rmi<ImageID>

There are many more things you can do with images. For this tutorial, these basic commands for images should be enough.

If you’re interested in the topic, check out other Docker tutorials or take an online course. Among other things, you’ll learn how to create your own images with a docker file and then run them as containers on any system.

Managing containers – The most important docker commands for containers

Containers are docker image instances that can be executed with the run command. Docker’s primary purpose is running containers to execute code more efficiently. Therefore, we will take a look at the most important Docker commands used in container management and a typical container lifecycle to illustrate them.

You need to understand the Docker lifecycle before you can start using the platform effectively. You need to know that each container in Docker has a lifecycle, which can be explained as follows:

  • In the initial phase of the container, it is specified as being in the created state.
  • After the run command has been executed, the Docker Container is determined to have been placed in the run state.
  • A Docker container will be deleted after the kill command has been invoked.
  • A Docker container will be paused after the pause command is used.
  • A Docker container is stopped after the stop command is used.
  • A stopped Docker container will run again after the run command is used.

You will be able to navigate the Docker interface much more easily after you understand these commands.

 
SHARE
Previous article“There will be no return to normal for business” – the conclusion of 28 global leaders
Next articleTackling ‘hidden’ energy costs could save big businesses millions – Business News Scotland

NO COMMENTS

LEAVE A REPLY