Beginners (transfer) Docker Getting Started Tutorial (2) Commands


Docker Getting Started Tutorial (2) Command

[Editor's Note] DockerOne has translated Flux7's Docker introductory tutorial. This article is the second in a series of introductory tutorials. It introduces the basic commands of Docker and the usage and functions of the commands.

In the first article of the Docker tutorial series, we learned the basics of Docker, how it works and how to install it. In this post, we'll learn 15 Docker commands and learn how it works by doing it.

First, let's check if Docker is installed correctly by running the following command:
docker info

if this command is not found, then Docker is not installed correctly. If installed correctly it will output something like the following:


  At this point there are no images or containers in Docker. So, let's pull a pre-built image with the command:
sudo docker pull busybox
BusyBox is a minimal Linux system that provides the main functionality, excluding some GNU-related features and options.

Next we'll run a Hello World example, let's call it "Hello Docker" for now.
docker run busybox /bin/echo Hello Docker
Now, let's run as a background process hello docker :
sample_job=$(docker run -d busybox /bin/sh -c "while true; do echo Docker; sleep 1; done")

sample_job The command will print Docker every second, you can use Docker logs it to view the output. If there is no name, the job will be assigned an id, and it Docker logs will become more troublesome to use commands such as viewing logs later.

Run Docker logs the command to see the current status of the job:
docker logs $sample_job

All Docker commands can be viewed with: The container
docker help
named sample_job , can be stopped with:
docker stop $sample_job
Restart the container with the following command:
docker restart $sample_job
If you want to remove the container completely, you need to stop the container , then it can be removed. Like this: to save the state of the container as an image, use the command: Note that the image name can only take characters [az] and numbers [0-9]. You can now view a list of all images with the following command: In our previous Docker tutorial , we learned that images are stored in the Docker registry. The image in the registry can be found with the following command: To view the historical version of the image, execute the following command: Finally, use the following command to push the image to the registry: You must know if the repository name is the root repository, it should use this format . These are all very basic Docker commands. In Chapter 6 of our Docker tutorial series , we'll discuss how to use Docker to run Python web applications, as well as some advanced Docker commands.
docker stop $sample_job docker rm $sample_job

docker commit $sample_job job1




docker images


docker search (image-name)

docker history (image_name)

docker push (image_name)
(user)/(repo_name)


 
 
 
 
 
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326484430&siteId=291194637