Miscellaneous Docker Commands
Below are a minimal set of Docker commands that you need to know to work with containers.
To open a shell window on an existing running container:
Use the following command with the container ID from the docker ps results:
# docker exec -it [container ID or Name] /bin/bash
To stop a running container:
Use the following command:
# docker stop [container ID or Name]
Docker stop stops all processes running in the container meaning any data in memory is lost and there is no CPU consumption, but the filesystem state of the container is preserved. It also shuts down the Docker engine process on the host. This is similar to turning off a computer.
Docker start will restart the Docker engine, restore from the saved filesystem state, and relaunch processes. Zixi licenses are preserved when containers are stopped and started.
To start a stopped container:
Use the following command:
# docker start [container ID or Name]
To pause a running container:
Use the following command:
# docker pause [container ID or Name]
Docker pause freezes all processes running in the container. Memory state is preserved as well as filesystem states, but there is no CPU consumption. The Docker engine process on the host remains active. This is similar to a computer in sleep mode.
Docker unpause will unfreeze the processes running in the container. Zixi licenses are preserved when containers are paused and unpaused.
To unpause a paused container:
Use the following command:# docker unpause [container ID or Name]
To remove a container:
Use the following command:
# docker rm [container ID or Name]
Removing a Docker container is similar to wiping the hard drive of a computer and the file system will no longer exist. Note, if the host where the Docker container is running reboots, that has the same implications as removing a container. The container’s file system will not be preserved and a new container must be started from the Docker image. After you have removed the container that uses an image, you can remove the image.
To remove an image:
Use the following command:
# docker image rm [image ID or Name]