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
Mysql limit paging statement usage Compared with ...
Table of contents 1. Event Processing Model 1. Ev...
Preface To modify file permissions in the termina...
Table of contents Preface Active withdrawal Excep...
Let's take a look at the detailed method of b...
<br />This example mainly studies two parame...
Table of contents 1. What is vuex 2. Installation...
If the server data is not encrypted and authentic...
Find two test machines: [root@docker1 centos_zabb...
1. Write a Mysql link setting page first package ...
1. Add the viewport tag to the HTML header. At th...
1. Before configuring the IP address, first use i...
Table of contents Backend: Rails API part Front-e...
Original Intention The reason for making this too...
as follows: -m, --memory Memory limit, the format...