Could not find the container on ExecStartPost directive
Posted on
Just having a try, I want to create a index.html file through binding from another container on ExecStartPost directive. When I run a plain Nginx container for testing, I don't want to prepare some data volume container or modified images for Nginx images beforehand. Using with ExecStartPost directives, I thought that it might be possible to get it, but actually I couldn't.
Just having a try, I want to create a index.html file through binding from another container on ExecStartPost directive. When I run a plain Nginx container for testing, I don’t want to prepare some data volume container or modified images for Nginx images beforehand. Using with ExecStartPost directives, I thought that it might be possible to get it, but actually I couldn’t.
My trash unit file
I executed docker run from a trusted dockerfile/nginx image. I added -v /var/www/html flag and binded from another container on ExecStart directive.
It seems that on ExecStartPost directive it could not be possible to find the container and to mount its volumes which creating by ExecStart. This causes whole unit start process to fail.
$ fleetctl submit system/nginx-minimal@.service $ fleetct load nginx-minimal@80.service $ fleetct start nginx-minimal@80.service $ fleetctl journal -f nginx-minimal@80.servece ... Nov 06 21:58:22 localhost systemd[1]: Starting Nginx Minimal Service... Nov 06 21:58:22 localhost docker[32496]: Error response from daemon: No such container: nginx-minimal80 Nov 06 21:58:22 localhost docker[32496]: 2014/11/07 10:58:22 Error: failed to kill one or more containers Nov 06 21:58:22 localhost docker[32506]: Error response from daemon: No such container: nginx-minimal80 Nov 06 21:58:22 localhost docker[32506]: 2014/11/07 10:58:22 Error: failed to remove one or more containers Nov 06 21:58:22 localhost docker[32521]: Pulling repository dockerfile/nginx Nov 06 21:58:25 localhost docker[32536]: Pulling repository busybox Nov 06 21:58:28 localhost systemd[1]: nginx-minimal@80.service: control process exited, code=exited status=1 Nov 06 21:58:28 localhost docker[32552]: 2014/11/07 10:58:28 Error response from daemon: Cannot start container 960cdce5ff448377aa5ef9c134f9fcd111715bfbe185c4fb2c86a2a240252114: Container nginx-minimal80 not found. Impossible to mount its volumes Nov 06 21:58:28 localhost docker[32574]: Error response from daemon: No such container: nginx-minimal80 Nov 06 21:58:28 localhost docker[32574]: 2014/11/07 10:58:28 Error: failed to stop one or more containers Nov 06 21:58:28 localhost systemd[1]: nginx-minimal@80.service: control process exited, code=exited status=1 Nov 06 21:58:28 localhost systemd[1]: nginx-minimal@80.service: main process exited, code=exited, status=2/INVALIDARGUMENT Nov 06 21:58:28 localhost systemd[1]: Failed to start Nginx Minimal Service. Nov 06 21:58:28 localhost systemd[1]: Unit nginx-minimal@80.service entered failed state.
It works by mounting a host directory
Update 2014-11-08
After two days I came up with that it could be possible by mounting a host directory on ExecStartPre directive. It works this time.