Home > database >  Can't run docker container in different user
Can't run docker container in different user

Time:02-17

I have 2 users on my ubuntu: personal and work. I created a docker image to run firefox in a container. To make things simple I added an alias in my .bash_aliases file to run it by typing "firefox" in terminal like so:

docker run --rm -d --name firefox \
-v $XDG_RUNTIME_DIR/pulse:$XDG_RUNTIME_DIR/pulse \
-e PULSE_SERVER=$XDG_RUNTIME_DIR/pulse/native \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=$DISPLAY \
--network host \
shallowduck/firefox:1.0

The problem is that firefox does not launch when I'm logged in as "work" user, only "personal".

  • When I run the command I get container id as output in terminal but nothing launches.
  • When I run docker ps, the container isn't there.
  • When I run docker ps -a, there is no trace that the container exited with an error or whatever.
  • Both users are part of the docker group.

I'm not sure what I'm missing. Any ideas would be appreciated.

CodePudding user response:

I fixed this by running this command in terminal:

xhost  

This adds host names on the list of machines that can connect to X server. I forgot I had to run this command for each user.

  • Related