mviereck / x11docker

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

How to deploy a container? #280

Closed ghost closed 4 years ago

ghost commented 4 years ago

This's the most noob question opened in this repo.

https://github.com/mviereck/dockerfile-x11docker-xfce i also understand about https://github.com/mviereck/dockerfile-x11docker-lxde#options

Single application: x11docker x11docker/lxde pcmanfm Full desktop: x11docker --desktop x11docker/lxde

what's the full docker run command?

Eg: if deploy any other common images (not related to x11docker or similar) docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx

pahansen95 commented 4 years ago

Are you asking how to deploy a container via x11docker like you would with docker run?

Or how to start a container with docker run & have it use the X Server x11docker created?

Or do you want to see the docker run command x11docker generates?

ghost commented 4 years ago

Are you asking how to deploy a container via x11docker like you would with docker run? Yes Or how to start a container with docker run & have it use the X Server x11docker created? Yes

pahansen95 commented 4 years ago

x11docker doesn't wrap docker such that you can pass docker flags to x11docker like you would w/ the docker run command.

For Example: docker run -it --rm -n my-container -e "FOO=BAR" ubuntu:20.04 'echo $FOO' isn't going to translate to x11docker -it --rm -n my-container -e "FOO=BAR" ubuntu:20.04 'echo $FOO'

Check out the wiki for more in depth information on what you can do.

You can also run x11docker -h on the command line for a list of all options.

If you get stuck on how to use a particular flag we might be able to help.

ghost commented 4 years ago

@pahansen95 i read wiki but to be honest i still couldn't realize that

https://github.com/mviereck/dockerfile-x11docker-xfce https://hub.docker.com/r/x11docker/xfce

can you tell me the full command for deploy a container using that image?

Ubuntu user.

pahansen95 commented 4 years ago

Can you help me understand? Are you trying to start a desktop environment? Are you trying to start a single Application on the desktop? Can you describe your current setup before running any commands?

ghost commented 4 years ago

Can you help me understand? Sure. i searched online about run GUI apps in docker then found this awesome project. Unfortunately i cannot realize how to use this. Lol. however i have average knowledge about docker even not as expert.

So i want to run eg: chromium, firefox, thunar, element(matrix) or something else similar xfce full desktop eg: above mention about both thunar and xfce full desktop

but i dont understand how to deploy that. can you understand now?

pahansen95 commented 4 years ago

I can't see what you are seeing so I don't know how to help. Can you describe where you are running these commands, what output you are seeing or the current configuration of your environment? Can you provide a debug log?

Have you read through the README? It is very descriptive on how to use this tool.

Maybe it's a frame of mind? Don't try deploying Docker containers yourself, let the tool do that for you.

The x11docker/xfce image can be used to start a containerized Desktop Environment (DE). If you want to run individual applications accessible in the DE you can start them using x11docker as well.

Sorry that's the best I can do w/ the limited view of your situation.

ghost commented 4 years ago

I can't see what you are seeing so I don't know how to help. Can you describe where you are running these commands, what output you are seeing or the current configuration of your environment?

I try one more time otherwise i might ask from someone else experienced about docker. i'm really asking very basic thing but your explanation looks like telling me there're sweet foods inside room but doesn't tell me how to open door while i know to eat very well. ;)

Tell me how to do that with x11docker as explain to beginner then i can be catch what i wanted to know.

i already have seen below details (but it doesn't helpful for me at the moment due unable to understand)

https://github.com/mviereck/dockerfile-x11docker-xfce
https://hub.docker.com/r/x11docker/xfce

Single application: x11docker x11docker/xfce thunar
Full desktop: x11docker --desktop x11docker/xfce
mviereck commented 4 years ago

Just run this command:

x11docker x11docker/xfce thunar

If it does not work, please show the terminal output.

ghost commented 4 years ago

Definitely host system doesn't recognize that. Here's the output. sudo: x11docker: command not found

mviereck commented 4 years ago

You need to install x11docker to use it. See: https://github.com/mviereck/x11docker#installation

ghost commented 4 years ago

@mviereck Solved :)

eine commented 4 years ago

x11docker doesn't wrap docker such that you can pass docker flags to x11docker like you would w/ the docker run command.

@pahansen95, note that it is possible to pass docker args, although some might conflict with x11docker's own args. So, you should not use -i or -t as in a regular docker cmd, but you can use -p, -e, -v... For example:

x11docker -i -- -p 8000:8000 -e CI=true -v $(pwd):/src -- image_name bash
# is equivalent to
docker -it      -p 8000:8000 -e CI=true -v $(pwd):/src -- image_name bash

A discussion about executing any of the commands above from VSCode: microsoft/vscode-docker#1496.

ghost commented 4 years ago

I have several questions. I believe @mviereck may know to answer for 1st question properly or @eine

1- Including above explanation there're some differences and limitations with x11docker arges. Again i'm bad at recognize details in wiki; then sorry if this already explained somewhere

Think if if i have deployed openvpn-client instance (normal docker instance not x11docker) https://github.com/dperson/openvpn-client https://hub.docker.com/r/dperson/openvpn-client/

With common docker deployments then it's easy to use sudo docker run -it --net=container:vpn -d some/docker-container

Then How to deploy eg: x11docker --desktop x11docker/xfce or x11docker --home xorilog/telegram to use --net=container:vpn?

2- Again i still haven't realized x11docker structure then simple question, how to view deployed or exited containers? i can find downloaded images using same docker images command but docker ps -a doesn't show x11docker containers.

mviereck commented 4 years ago

From x11docker --help:

Usage:
To run a Docker container on a new X server:
  x11docker IMAGE
  x11docker [OPTIONS] IMAGE [COMMAND]
  x11docker [OPTIONS] -- IMAGE [COMMAND [ARG1 ARG2 ...]]
  x11docker [OPTIONS] -- DOCKER_RUN_OPTIONS -- IMAGE [COMMAND [ARG1 ARG2 ...]]
To run a host application on a new X server:
  x11docker [OPTIONS] --exe COMMAND
  x11docker [OPTIONS] --exe -- COMMAND [ARG1 ARG2 ...]
To run only an empty new X server:
  x11docker [OPTIONS] --xonly

You can add custom DOCKER_RUN_OPTIONS between -- --. Example.

x11docker -- --net=container:vpn -- x11docker/xfce xfce4-terminal.

docker ps -a doesn't show x11docker containers.

It shows them while they are running. After terminating the applications they are removed. Sample output here:

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
cb9c3d719a4c        x11docker/firefox   "env /usr/local/bin/…"   6 hours ago         Up 6 hours                                      x11docker_X105_x11docker-firefox_14877360102
eine commented 4 years ago

@azrea, you can optionally give a explicit name to the container (as an argument to x11docker, NOT docker), for finding it more easily.

ghost commented 4 years ago

Thank you both @mviereck and @eine ^_^

ghost commented 4 years ago

It shows them while they are running. After terminating the applications they are removed.

@mviereck Is it possible to configure for keep containers without getting removed even after terminating application or stopped them. Because it's quite difficult to keep some preferences and custom configurations in external persistent files

mviereck commented 4 years ago

Sorry, that is not possible. You can use option --home to store persistent data, especially user configuration. Alternatively, use docker build instruction VOLUME. Single configurations that you want to keep forever can be done in the Dockerfile.