Phenomenon Start the Docker container docker run –name [CONTAINER_NAME] [CONTAINER_ID] Check the running status of the container docker ps -a It is found that the mydocker container just started has exited reason It is very important to point out that for a Docker container to run in the background, there must be a foreground process. If the command run by the container is not a command that has been suspended (such as running top or tail), it will automatically exit. The main thread of the docker container (the command executed by CMD in the dockerfile) ends and the container exits Workaround You can use interactive startup docker run -i [CONTAINER_NAME or CONTAINER_ID] The above is not very friendly, it is recommended to use background mode and tty options docker run -dit [CONTAINER_NAME or CONTAINER_ID] View container status docker ps -a Docker calls out the background container docker attach [CONTAINER_NAME or CONTAINER_ID] Tips: When exiting, use [ctrl + D], which will end the current Docker thread and the container. You can use [ctrl + P] [ctrl + Q] to exit without terminating the container. The following command will execute the specified command in the specified container. [ctrl+D] will not terminate the container after exiting. docker exec -it [CONTAINER_NAME or CONTAINER_ID] /bin/bash 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:
|
<<: A brief talk about React Router's history
The following two functions are used in the same ...
1. Demand The backend provides such data for the ...
This article shares the specific code of JavaScri...
MySQL Advanced SQL Statements use kgc; create tab...
background When we talk about transactions, every...
answer from stackflow: Simply <br> is suffic...
Now .net core is cross-platform, and everyone is ...
Preface I just started learning MySQL and downloa...
Table of contents chmod Example Special attention...
When inserting a set of data into the MySQL datab...
Preface Today I encountered a very strange proble...
Use JS to implement a random roll call system for...
question Recently I encountered a requirement to ...
Method 1: Download Pycharm and install Download a...
Table of contents Preface Can typeof correctly de...