1. Start the Docker container Start a new Docker container using the command below. This will start a new container and give you access to it using the /bin/bash shell. # docker run [OPTIONS] <IMAGE NAME> [COMMAND] [ARG...] For example, the command below will create a new docker container using the image named "ubuntu". To list all available images, use the docker images command. # docker run -i -t ubuntu /bin/bash To exit the Docker container, press ctrl+p+q. This will keep the container running in the background and provide the host system console. If you use the exit command, it will stop the current container. 2. List Docker containers Once inside the Docker container, execute the following command to list all running containers. # docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f2582758af13 ubuntu "/bin/bash" 2 hours ago Up 2 hours first_ubuntu By default, the command above will only list running containers. To list all containers including stopped ones, you need to use the following command. # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f2582758af13 ubuntu "/bin/bash" 2 hours ago Up 2 hours first_ubuntu 6b5b5a969241 centos "/bin/bash" 2 days ago Exited (0) 24 hours ago ubuntu-web 3. Start/Stop/Connect Container You can start, stop, or attach to any container using the following commands. To start the container, use the following command. # docker start <CONTAINER ID|NAME> To stop the container, use the following command. # docker stop <CONTAINER ID|NAME> To attach to the currently running container, use the following command. # docker attach <CONTAINER ID|NAME> 4. Discard Docker containers Before deleting any container, make sure the container is stopped. You can list the status of the container using the 'docker ps -a' command. If the container is still running, first stop it using the given command in the above steps. Now remove single or multiple containers using the following command. # docker rm <CONTAINER ID|NAME> <CONTAINER ID|NAME> You can also remove all stopped containers at once using the following command. # docker rm $(docker ps -a -q) You may also be interested in:
|
<<: Detailed example of clearing tablespace fragmentation in MySQL
>>: How to introduce scss into react project
Table of contents Preface Common methods 1. Modif...
<br />Most of the time when we talk about na...
Detailed example of database operation object mod...
Table of contents 01. Use useState when render is...
Problem: When using JDBC to connect to the MySQL ...
MySQL versions are divided into Enterprise Editio...
Table of contents 1. Problem scenario 2. Cause An...
Table of contents What are immutable values? Why ...
Table of contents Master-slave replication mechan...
Preface Recently I encountered a requirement, whi...
The application of containers is becoming more an...
Configuration steps 1. Check whether DNS is confi...
Table of contents Background Description Creating...
This article is based on the Windows 10 system en...
This article is original by 123WORDPRESS.COM Ligh...