docker-opener icon indicating copy to clipboard operation
docker-opener copied to clipboard

Users wrong user

Open lolmaus opened this issue 2 years ago • 4 comments

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.

lolmaus avatar Aug 25 '22 15:08 lolmaus

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.

artemkaxboy avatar Aug 25 '22 17:08 artemkaxboy

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:/$ 

artemkaxboy avatar Aug 25 '22 17:08 artemkaxboy

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
    

lolmaus avatar Aug 26 '22 07:08 lolmaus

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.

leleogere avatar Mar 15 '24 11:03 leleogere