Learn How To Create A Docker Container In 132 Seconds

By Lukas Aichbauer and Ivan Popovic | March 21, 2024 | 2 min watch time

Description

Learn all the commands needed to start, manage and interact with a Docker Container in 132 seconds.

Learning outcomes

  • What is a Docker Container?
  • How do I create my first Docker Container?
  • What commands do I need?
  • How do the commands work together?
  • How do I manage and interact with a Docker container?

Commands You Will Learn

docker run <image-name/image-id> – start a Docker container (a running instance of a Docker image)

--detach – add this flag to the docker run command if you want to run the container in a background process

--publish <host-port>:<container-port> – add this flag to the docker run command if you want to forward a container port to the host system (e.g., --publish 3000:3000). This is useful if you want to access the program running in your container from the host system (e.g., a REST API hosted on port 3000 in the container)

docker stop <container-name/container-id> – stop a Docker container

docker rm <container-name/container-id> – remove a Docker container completely

docker restart <container-name/container-id> – restart a stopped Docker container (a removed container cannot be restarted)

docker container ls – list all running containers

--all – add this flag to the docker container ls command if you want to list all containers, including stopped containers