Launch a Container on Docker in GUI Mode

X Servers

version: "3"services:
app:
image: my-app:latest
build: .
environment:
- DISPLAY=${DISPLAY}
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
network_mode:host
FROM centos:latest
RUN apt-get update && apt-get install -y firefox
CMD ["/usr/bin/firefox"]
docker-compose build
docker-compose up

Task Objective:

Now we will learn how to launch docker container with capability of GUI

Another Approach — Running a VNC Server

FROM ubuntu:latest
RUN apt-get update && apt-get install -y firefox x11vnc xvfb
RUN echo "exec firefox" > ~/.xinitrc && chmod +x ~/.xinitrc
CMD ["v11vnc", "-create", "-forever"]

Conclusion

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store