mviereck / x11docker

Run GUI applications and desktops in docker and podman containers. Focus on security.
MIT License
5.62k stars 378 forks source link

Docker run argument --name not working #61

Closed sandrokeil closed 6 years ago

sandrokeil commented 6 years ago

It would be great if I can set the name of the Docker container. If I try x11docker -- --name=cathode jess/cathode it fails with Error response from daemon: no such image: x11docker_X100_3c3ea8_jess-cathode: invalid reference format: repository name must be lowercase. I'm not sure if it is because of the duplicate --name argument in the docker run command.

Adding an optional x11docker argument --name would be useful to set an own Docker container name to identify this container in a network via the name. I need this for debugging. I have an IDE Docker Container and a Docker Compose network. I join the IDE Docker Container to the Docker Compose network but I have to set the debug host IP/Name (the IDE Docker Container in this case) manually.

What do you think or are there any problems with setting a custom container name?

mviereck commented 6 years ago

Your setup failed because x11docker checks for successfull startup using the container name and believes that the startup failed.

One possibility is to use option --showid that gives the container ID on stdout. This ID is equivalent to the container name:

read ID < <(x11docker --showid image)

An option --name for a custom container name is reasonable. One issue: Option --cleanup checks for containers that did not terminate successfully and removes them. The check relies on x11docker_X as part of container name.

Would --showid be ok, or would you prefer a meaningful name instead of an anonymous number? Be aware that a custom --name will fail if a container with same name is already in docker ps -a, e.g. due to a failed stop. The ID will always be unique and won't fail.

sandrokeil commented 6 years ago

The Docker container id will work too. The problem is, that the container ID will change on every startup so I have to update my debug config every time.

I can live with the drawbacks of using a custom container name. It's only a special use case but I think it can be useful for others too.

Time for a new PR? ;-)

mviereck commented 6 years ago

Time for a new PR? ;-)

yeah :-)

To reduce the issue with --cleanup you could create a file container.name that is checked in cleanup() additonally to current check of x11docker_X in docker ps -a.