docker run -ti ubuntu:latest bash
docker ps -l // last running docker container docker ps -a // all containers
docker exec -it bash
docker commit This outputs a SHA
We can use the image to run a new container
docker run -ti bash
docker rm
Delte the container once it runs the bash script docker run --rm -ti ubuntu:latest bash -c "sleep 5 ; echo done"
docker run -d ubuntu:latest ex. running the node web-server in detached mode.
docker kill <container id / name> : stops the container docker rm <container id / name > : removes the container
Q.) Why all containers are showing exited :
╭─krchopra@krchopra-Mac ~/Workbook/miscellaneous-daily ‹master›
╰─$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9ee2b4d6eb6a fedora:latest "/bin/bash" 14 seconds ago Exited (0) 13 seconds ago exciting_boyd
646371d5df56 ubuntu:latest "bash" 55 seconds ago Exited (0) 54 seconds ago agitated_lehmann
Till the time I am in the container: the container was running : as soon as i exited the terminal, the container terminated too.
docker logs <contaner-id / name>