docker-opener
docker-opener copied to clipboard
Users wrong user
Hi!
My Dockerfile
has this:
USER node
When I do docker exec -it foo-myapp-1 /bin/bash
, I enter the container as the node
user.
But when I do opener myapp
, I enter the container as the root
user.
How do I make opener
enter as the non-root user? Preferrably as one-time configuration, since the whole point of opener
is brevity.
Hello, thanks for your report!
You are right, default user to shell in to container is always root. I'll consider passing standard user option to connect command, it should be something like this:
opener myapp --user node
Not sure when exactly it'll be added, though.
Meanwhile workaround with su
can be used if the container provides it
user:host~$ opener node
Found container with image `node` containing `node`
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c1b87e1ceaad node "docker-entrypoint.s…" 11 minutes ago Up 11 minutes serene_feynman
Found native shell: bash
Connecting...
root@c1b87e1ceaad:/# whoami
root
root@c1b87e1ceaad:/# su node
node@c1b87e1ceaad:/$ whoami
node
node@c1b87e1ceaad:/$
Should be su -s /bin/bash node
in my case, otherwise the prompt is just $
, missing the username and the path.
It kinda defeats the purpose of opener because together with the invocation of opener it's not shorter than the old-school invocation:
-
opener bar su -s /bin/bash node
-
docker exec -it foo-bar-1 /bin/bash
Being able to pass a user would be very useful. Actually, I do think that the default should be to use the user specified in the dockerfile, and to be able to pass --user root
to log in as root if needed.