Basic Docker commands

Adela Chao
Jun 9, 2022

--

docker build -t [image tag]

Build a new image, and give this image a tag name.

docker run [image id or image tag]

Create and start a container by image id or by image tag.

docker run -it [image id or image tag] [cmd]

Create and start container, and also provide a command to override the default command.

docker ps

Display information about all of the running containers.

docker exec -it [container id] [cmd]

Execute the given command in a running container.

docker logs [container id]

Get all logs that is emitted from the primary process of the given container.

docker system prune

Removes all stopped containers, dangling images, and unused networks

--

--