HomeProjectsArticlesNotesAbout

Docker Notes 2020

docker
notes

Common Commands

Containers

docker run node

Runs and instance 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

docker images

Shows a list of images

docker rmi node

removes an image Note: the image cannot be in use by any container

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

Docker Tutorial for Beginners

For Review

  • port mapping
  • volume mapping

More Articles

All Articles

Links

Home Articles Notes Projects About Style Guide Site Credits

Contact

ย connect@dev.lucaszapico.space

Location

๐ŸŒŽ Earth