ibuildthecloud / systemd-docker

Wrapper for "docker run" to handle systemd quirks
Apache License 2.0
721 stars 111 forks source link

Bad Argument Parsing Destroys "Unrelated" Containers #28

Open alexmipego opened 9 years ago

alexmipego commented 9 years ago

I've been having trouble with a new setup and I believe I've found a major issue with systemd-docker. I've the following on my unit file:

ExecStart=/opt/bin/systemd-docker --cgroups name=systemd run \ --name postgres-ambassador \ -v /var/run/docker.sock:/docker.sock \ -p 127.0.0.1:5432:5432 \ --expose 5432 \ --rm \ cpuguy83/docker-grand-ambassador \ -name postgres \ -sock /docker.sock

As you can see, the container I want to run is named postgres-ambassador and one of the arguments the container receives is "-name postgres". The issue here is that systemd-docker's argument parsing seems to be using "postgres" as the controlled container, instead of the correct "postgres-ambassador".

This is a major issue because it will stop and remove the wrong container. As it is right now, the postgres unit (also launched using systemd-docker) doesn't fail but the container is stopped and destroyed. Trying to restart postgres-ambassador will fail because it's trying to "--rm postgres" and launching "postgres-ambassor" which docker refuses due to a conflicting name. Meanwhile, all links and dependencies to "postgres" will cascade fail.