# 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 --- ## 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 - [download alpine linux](https://alpinelinux.org/downloads/) - [dockerhub alpine image](https://hub.docker.com/_/alpine) - [docker glossaire](https://docs.docker.com/glossary/) - [Dockerfile syntaxe](https://docs.docker.com/engine/reference/builder/) - [determine the parent image](https://forums.docker.com/t/determine-the-parent-image/48611) - [docker image from scratch](https://codeburst.io/docker-from-scratch-2a84552470c8) - [build context and image context](https://stackoverflow.com/questions/55108649/what-is-app-working-directory-for-a-dockerfile/55109065#55109065) - [pid1 docker problem](https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/) #### install and use docker and compose - [how to install docker engine](https://docs.docker.com/engine/install/ubuntu/) - [github releases](https://github.com/docker/compose/releases) - [install last version of compose manually](https://docs.docker.com/compose/install/compose-plugin/#install-the-plugin-manually) - [install manually SO discussion](https://stackoverflow.com/questions/57456212/error-version-in-docker-compose-yml-is-unsupported) - the version installed with apt is 1.17.1, way out of date **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 - `sudo curl -L "https://github.com/docker/compose/releases/download/2.10.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose` - `sudo chmod +x /usr/local/bin/docker-compose` - `sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose` **build and run a docker image** - be in directory with a Dockerfile - `sudo docker build --tag .` - `sudo docker images` to list images - `sudo docker run ` - `sudo docker image rm -f ` **execute a docker-compose file** - be in directory with a docker-compose.yml file - `sudo docker-compose up` #### volumes vs bind mounts * [docker doc: use volumes](https://docs.docker.com/storage/volumes/) * [docker doc: use bind mounts](https://docs.docker.com/storage/bind-mounts/) * [comparison volume vs bind mounts](https://devopscook.com/docker-volumes-vs-bind-mounts/) * [fundamentals use of volumes and bind mounts](https://medium.com/dlt-labs-publication/bind-mounts-volumes-in-docker-81523303cbb4) * [how volumes and bind mounts are really differents](https://serverfault.com/questions/996785/docker-volumes-vs-mount-binds-what-are-the-use-cases) - 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](https://docs.docker.com/engine/install/linux-postinstall/)