Docker Cheatsheet
- pull a image from remote docker repo
docker pull ubuntu
- run the image to generate a container
docker run -it ubuntu /bin/bash
- show all containers
docker ps
or
docker ps -a
- start a container
docker start container_id
- running in background
docker run -d --name container_name ubuntu /bin/bash
- stop a container
docker stop container_id
- restart a container
docker restart container_id
classic command
-P (random port)
-p 5000:5000 (mapping app port 5000 to server port 5000)
-d (detach running app on background)
-it (interactive terminal)
- remove container
docker rm container_id
docker rm -f container_id (force remove container)
- look up container process
docker top container_id or name