...
Notes about containers
Exiting the container
- The container can be exited by typing
exitfrom the active container. - A container can be stopped from a terminal on the host system
- Once exited all data and changes made within the container will be lost. Hence, if necessary, it is important to
- Push any code changes back to a repo
- If data is required either set-up a data volume or copy the data back to a local machine, using
docker cp
...
Executing docker run will always create a new container, which will be retained if the run command does not include the --rm. This is not ideal and so here are some commands to manage the containers
List running containers
Code Block language bash theme Midnight docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d1bd89ccc47f openifs-48r1.1 "bash" 15 hours ago Up 5 seconds beautiful_pasteurIf no container
...
is running on your system, then only CAPITAL headings are returned with
docker psList all containers (running and exited)
Code Block language bash theme Midnight docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d1bd89ccc47f openifs-48r1.1 "bash" 15 hours ago Exited (0) 4 seconds ago beautiful_pasteurNotice that the
STATUSisExited, rather thanUp, as in (1)- Start an existing container