Categories
linux programming web server

Docker

Containerization is the process of encapsulating software code along with all of its dependencies inside a single package so that it can be run consistently anywhere. Docker is an open source containerization platform. It provides the ability to run applications in an isolated environment known as a container.

Containers are lightweight virtual machines that can run multiple containers simultaneously. Containers can be deployed on servers.

Images are multi-layered self-contained files with necessary instructions to create containers. Containers are runnable instances of images. If we compare images with classes from OOP then containers are the objects. Images are stored in registries such Docker Hub, the default public registry for storing images.

Arch install

pacman -Sy docker docker-compose
systemctl start docker.service
gpasswd -a benke docker
docker info
kitematic

Images commands

docker images
docker image ls
docker rmi [image_id]
docker run [image_id]
docker create [image_id]
docker start [container_id]
docker run [image_id] -d
docker pull [image_id]

Containers commands

docker run -it docker/whalesay cowsay Petar
docker run -it -p 80:80 nginx
docker ps
docker ps -a
docker container ls
docker start [container_id]
docker restart [container_id]
docker exec [container_id] [command]
docker logs [container_id]
docker stop [container_id]
docker rm [container_id]
docker container rm --force [container_id]
docker system prune
docker inspect [container_id] (look for RestartPolicy in the output)
docker update --restart=no [container_id]

Dockerfile

  • FROM
  • WORKDIR
  • COPY
  • RUN
  • EXPOSE
  • ENTRYPOINT
  • CMD

Source: freeCodeCamp

Leave a Reply

Your email address will not be published. Required fields are marked *