Docker Commands
Explore essential Docker commands to manage MySQL containers including viewing, stopping, restarting, and removing containers. Understand how to create custom Docker networks for reliable container communication. Learn to perform database backups with docker exec, gaining practical skills to efficiently handle MySQL in Docker environments.
We'll cover the following...
View, stop, and restart containers
Containers running in interactive mode (started with the -it switch) can normally be stopped by pressing Ctrl|Cmd + C.
๐ However, applications will not always shut down gracefully or signal they have terminated. If an interactive container fails to stop, youโll need to execute the
stopcommand described below.
A list of running containers can be viewed by entering:
docker container ls
or the shorter:
docker ps
Practice
Letโs try running the commands:
-
Click to connect to the terminal and then open another terminal, too.
-
List the running containers.
๐ Keep the tab open. We will be running more commands in it.
A list of active containers is displayed. This can be quite wide. A truncated version is shown here:
CONTAINER ID IMAGE STATUS PORTS NAMES
ef3bab04fc8f adminer Up 16 mins 8080->8080/tcp adminer
793003e459e6 mysql Up 17 mins 3306->3306/tcp mysql
Each container is assigned a hexadecimal ID that can be used as a reference in Docker commands. However, specifying a container ...