- What is a container and what problems does it solve?
- Container repository - Where do containers live
- Before and After Container
- What is a container?
- Difference between Docker and Virtual Machine
original post from docker documentation
- update the apt package index:
sudo apt-get update
- install packages to allow apt to use a repository over HTTPS
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
- adding docker's official GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
- setup the repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- list of available in the repo
apt-cache madison docker-ce
- install docker engine
sudo apt-get update
sudo apt install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io docker-compose-plugin
- build an image
docker build [optins] .
-t "app/container_name"
- create the container
docker create [options] IMAGE
-a, --attach # attach stdout, stderr
-i, --interactive # attach stdin (interactive)
-t, --tty # pseudo-tty
, --name # name your image
-p, --publish 5000:5000 # port map
, --expose 5432 # expose a port to linked containers
-P, --publish-all # publish all port
, --link container:alias # linking
-v, --volume pwd:/app # mount (absolute paths needs)
-e, --env NAME=hello # env vars
- run the container
docker run [options] IMAGE
# see `docker create` for options
- start the container
docker start [container ID or NAME]
- stop the container
docker stop [container ID or NAME]
- kill the container
docker kill [container ID or NAME]
- suspend the container
docker pause [container ID or NAME]
- resume the container
docker unpause [container ID or NAME]
- destroy the container
docker rm -f [container ID or NAME]
- list running containers
docker ps
- list all containers
docker ps -a
- show the container output (stdout, stderr)