Current Size:
Chakra BreakPoints
base0px
sm480px
md768px
lg992px
xl1280px
2xl1536px
Current Height:Width
widthpx
heightpx

Subjects

Docker Notes 2020

Date Created: 2020/10/21

Last Update: 2023/03/01

#cheatsheet #docker #notes

Common Commands

Containers

docker run node

Runs and instances of an image. If the image does not exist docker will pull an instance

docker ps

List running containers and basic information

docker ps -a

List containers both running or stopped and basic information

docker stop silly_sammet

Stops a running container

docker rm silly_sammet

Remove a stopped container run docker ps -a to confirm removal

docker run -p 80:80 docker/getting-started

Runs docker in the foreground

docker run -d -p 80:80 docker/getting-started

the -d flag will run docker in the background

docker attach <id>

or

docker attach <name>

Interactive Terminal

By default docker containers do not accept inputs through the terminal to enable this use the -it flag for interactive terminal

docker run -it

Port Mapping

docker

Tags

docker run node:12

A tag is a flag to specify a particular flavor of an image, the command without a tag will default to latest

Images

Show Images

docker images

Remove an Image

Note: the image cannot be in use by any container

docker rmi node
docker run node

Runs and image if the image already exists on machine else pulls latest image and runs.

Run Container

docker run --rm -it -p 3000:3000/tcp <imageName>
docker pull node

Pulls an instance of an image

Containers only run as log as the process they contain is running is live, such as a database or web service.

Build Image

docker build .

or

docker build ./path/to/dir

or best practice tag your image with a name

docker build . -t <imageName>

Reference

Anatomy of a DockerFile

For Review

  • port mapping
  • volume mapping

More Notes

All Notes
HomeProjects

Links

Home Articles Notes Projects About Style Guide Site Credits

Contact

 [email protected]

Location

🌎 Earth