t also adds complexity to the Dockerfile language when there are clear workarounds. Don't push so much config in the parent Dockerfile and leave if for the inheriting images instead. (aka: stop sourcing random images on docker hub :D)
Since docker 17.05 there is also a new way to do multi-stage builds that removes most of the need for this issue (this is a single Dockerfile):
FROM nginx AS source-image
FROM scratch
COPY --from=source-image / /
EXPOSE 80
STOPSIGNAL SIGTERM
CMD ["nginx", "-g", "daemon off;"]
EDIT: Forgot to say, the second solution squashes all previous layers. I don't think it's a big deal but it's good to know.
Quand on utilise une image comme celle là, il ne faut pas faire n'importe quoi comme installer des packages php5-extensions, ce n'est pas du tout prévu... Il faut suivre la doc et utiliser les outils mis à dispo sinon on se retrouve un Dockerfile qui n'a aucun sens...
Dans ma todo : migrer ces "choses" pour utiliser une image debian de base
wget -q https://registry.hub.docker.com/v1/repositories/debian/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}'
En gros pour dockeriser une app symfony pre 3.2 (ET 2.7 minimum) :
sed -i "s/PLACEHOLDER/PassEnv $(env|grep -Po 'SYMFONY__[^=]+'| paste -s -d' ')/" test.file
A partir de symfony 3.2 c'est beaucoup plus facile car les variables d'environnements sont directement accessibles dans les fichiers de configuration
Today I got a docker daemon not responding to commands (docker ps, docker run...)
Even after restarting service
In /var/log/docker I got this:
time="2017-03-01T08:28:58.43946917Z" level=fatal msg="open /var/run/docker/libcontainerd/containerd/81623262351dfc42c5e87aa8df11592a57f2d14a468476620c7c4d6c89de1958/state.json: no such file or directory"
The solution was to stop docker service, remove this /var/run/docker directory and restart docker service
docker stop command send SIGTERM to pid1 inside the container to let a chance to stop gracefully (https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/)
Unfortunatly some software ignore SIGTERM and need to be stopped by their own command (hello opendj)
To do so, in the Dockerfile, in the CMD, I use a script like this :
/thecommand/tostart/thesoftware/inbackground
trap "/thecommand/tostop/thesoftware" SIGTERM
while true; do sleep 1; done
so my script is run with PID1, docker stop sends SIGTERM, my script catch (trap) the signal, and run the command to stop gracefully
TIL what is this offical repository :
Only debian with some useful package to build dependencies (needed when you install some gem for example)
For example ruby:2.3 Dockerfile use a buildpack-deps image
I don't know if this shit is expected (normal behaviour or not) but this is annoying
bash :
$ toto=tata
$ echo $toto
tata
$ toto='tata'
$ echo $toto
tata
$ toto="tata"
$ echo $toto
tata
avec docker run -e
$ docker run -e toto=tata -it debian:jessie bash
root@5de64152ed05:/# echo $toto
tata
$ docker run -e toto='tata' -it debian:jessie bash
root@99a6b62f595c:/# echo $toto
tata
$ docker run -e toto="tata" -it debian:jessie bash
root@ab7581c30734:/# echo $toto
tata
avec docker run --env-file:
$ cat env.file
toto="tata"
$ docker run -it --env-file env.file debian:jessie bash
root@805480de4a52:/# echo $toto
"tata"
$ cat env.file
toto='tata'
$ docker run -it --env-file env.file debian:jessie bash
root@004b88cc448d:/# echo $toto
'tata'
$ cat env.file
toto=tata
$ docker run -it --env-file env.file debian:jessie bash
root@2ca9908d1cdf:/# echo $toto
tata
avec docker compose:
$ cat docker-compose.yml
version: '2'
services:
foo:
image: debian:jessie
container_name: foo
environment:
docker-compose up -d
docker exec -it foo bash
root@71a9a886cc24:/# echo $toto1
tata
root@71a9a886cc24:/# echo $toto2
"tata"
root@71a9a886cc24:/# echo $toto3
'tata'
Sympa les petites nouveautés!
docker system df
docker system prune
CLI restructured <3
Improved CLI backwards compatibility <3
Compose file version 2.1 and up
Healthcheck configuration can now be done in the service definition using
the healthcheck parameter
Containers dependencies can now be set up to wait on positive healthchecks
when declared using depends_on. See the documentation for the updated
syntax.