1. A container is an independently running application or a group of applications and their operating environment. Container is an important concept in Docker. 2. There are three ways to start a docker container a. Interactive mode: create a new container based on the image and start it For example, we can start a container and print out the current calendar table [root@rocketmq-nameserver4 ~]# docker run my/python:v1 cal ##my/python:v1 is the image name and tag We can also start a bash interactive terminal by specifying parameters. [root@rocketmq-nameserver4 ~]# docker run -it my/python:v1 /bin/bash The -t parameter tells Docker to allocate a pseudo terminal and bind it to the container's standard input, and the -i parameter keeps the container's standard input open. Use the docker run command to start the container. The standard operations that docker runs in the background include: 1. Check whether the specified image exists locally. If not, download it from the public warehouse my/sinatra:v2 is a modified image based on the training/sinatra image. training/sinatra is an image on a public repository. b. Short-term method : directly start a terminated container You can use the docker start command to directly start a terminated container. [root@rocketmq-nameserver4 ~]# docker run my/python:v1 /bin/echo hello test hello test After the command is executed, the console will print "hello test" and the container will terminate, but it will not disappear. You can use "docker ps -n 5" to view the latest 5 containers. The first one is the container just executed. You can execute it again: docker start container_id However, this time the console cannot see "hello test", only the ID can be seen, which can be seen using the logs command: docker logs container_id. You can see two "hello test" because the container was run twice. c. Daemon mode, running in guard mode That is, let the software run as a long-term service, this is SAAS! For example, we start the centos background container and print the calendar of the day every second. $ docker run -d centos /bin/sh -c "while true;do echo hello docker;sleep 1;done" After starting, we use docker ps -n 5 to view the container information To view the output in the started centos container, you can use the following method: $ docker logs $CONTAINER_ID ##View the output outside the container $ docker attach $CONTAINER_ID ##Connect to the container and view it in real time: 3. Terminate the container Use docker stop $CONTAINER_ID to terminate a running container. And you can use docker ps -a to view the terminated containers. A terminated container can be restarted using docker start. Use the docker restart command to restart a container. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Sample code for implementing multiple selection based on nested Table in ElementUI
>>: View MySQL installation information under Linux server
Deleting a table is not very common, especially f...
Table of contents 1. Don’t treat objects as Maps ...
Preface A classmate is investigating MLSQL Stack&...
Table of contents 1minio is simple 2 Docker build...
1 Question The company's server uses Apache, ...
This article shares the specific code of js to im...
Table of contents The dynamic particle effects ar...
First, download a series of things from the Alipa...
Table of contents What is Flattening recursion to...
What is Let’s first look at the concept of Docker...
This article shares with you the solution to the ...
1. I downloaded QT5.13 version before, but after ...
I don't know if you have noticed when making a...
Preface Nginx is a lightweight HTTP server that u...
Today, database operations are increasingly becom...