3.6 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 ?
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
working
FROM scratch
WORKDIR /
COPY hello /
CMD [ "/hello" ]
working, when WORKDIR is absent, it's default is set to "/"
FROM scratch
COPY hello /
CMD [ "/hello" ]
not working, when CMD execute in shell form, instead of exec form []
FROM scratch
COPY hello /
CMD /hello
not working, because c executable need library <unistd.h>
FROM scratch
COPY hello_c /
CMD [ "/hello_c" ]
not working, when executable is copied to ".", because WORKDIR value is not "." but "/" since we gave it a relativ path so it was build in top of the implicit absolut path "/"
FROM scratch
WORKDIR .
COPY hello .
CMD [ "hello" ]
not working, when WORKDIR is set to the present directory and executable is not copied, because the workdir is not the present directory but a directory in the file system of docker : executable need to be copied there to function
FROM scratch
WORKDIR /home/simplonco/Desktop/42/14_inception/inception/srcs/requirements/mariadb
CMD [ "hello" ]
working, because "hello" is copied to "/" and execute from "/"
FROM scratch
WORKDIR .
COPY hello /
CMD [ "/hello" ]
ressources
- how to install docker engine
- download alpine linux
- dockerhub alpine image
- docker glossaire
- Dockerfile syntaxe
- determine the parent image
- docker image from scratch
- build context and image context
docker compose
- github releases
- install last version of compose manually
- install manually SO discussion
- the version installed with is 1.17.1, way out of date
volumes vs bind mounts
- docker doc: use volumes
- docker doc: use bind mounts
- comparison volume vs bind mounts
- fundamentals use of volumes and bind mounts
- how volumes and bind mounts are really differents
- 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