Files
42_INT_13_inception/README.md
2022-08-30 11:35:11 +02:00

5.7 KiB

inception

This README would normally document whatever steps are necessary to get your application up and running.


questions

  • ? what means mounted in "a file or directory on the host machine is mounted into a container" ?
  • ? why the volumes cannot be modify outside docker ?

nginx basics

  • sudo netstat -tulpn to print network connections and see if nginx is running
  • or : ps -ax | grep nginx
  • sudo nginx -s quit to stop it
  • sudo docker system prune -af --volumes -> -a also unused images, -f without prompt for confirmation
    • remove stopped containers
    • remove unused networks
    • remove unused images
    • remove build cache
  • sudo docker ps -q all runnings containers
  • sudo docker stop $(sudo docker ps -q) stop all runnings containers

Dockerfile basics

  • the container posess its own filesystem
  • we need to copy the files it uses inside this filesystem
  • we can do that with COPY

ressources

docker pid 1

install and use docker and compose

remove old versions

  • sudo apt remove docker docker-engine docker.io containerd runc preparing directory
  • sudo apt update
  • sudo apt install ca-certificates curl gnupg lsb-release
  • sudo mkdir -p /etc/apt/keyrings
  • curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
  • 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 installing docker engine
  • sudo apt update
  • sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin check if installation worked
  • sudo docker run hello-world installing docker compose checked version on github release, see above
  • notice the 'v' below, before the version name (docker doc has it wong)
  • sudo curl -L "https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  • sudo chmod +x /usr/local/bin/docker-compose build and run a docker image
  • be in directory with a Dockerfile
  • sudo docker build --tag <name> .
  • sudo docker run <name>
  • sudo docker images to list docker images
  • sudo docker image rm <number>
  • sudo docker ps to list docker processes
  • sudo docker ps rm <name> execute a docker-compose file
  • be in directory with a docker-compose.yml file
  • sudo docker-compose up

volumes vs bind mounts

  • bind mounts are normal files anywhere on the computer, that docker container can access with absolut path and modify. They can also be modified without docker, since they are juste files
  • volumes are only modifiable by docker, they don't need an absolut path, and they are not dependent of host architecture

tips

run without sudo on linux