I try to create a container that has a volume between my host and the container by specifying it on my docker-compose file but after the build and the container has started impossible for me to find the folder of the volume.
Here is my docker-compose.yml
version: "3.8"
services:
app:
image: myworkenv:latest3
container_name: myWorkEnv060820
build:
context: .
dockerfile: Dockerfile3
args:
- DISPLAY=$DISPLAY
environment:
- PUID=1000
- PGID=1000
#- DISPLAY=${DISPLAY}
#- DISPLAY
- MYVAR=RANDOM
network_mode: host
restart: unless-stopped
And here is the Dockerfile used to build the image
FROM ubuntu:20.04
ARG DISPLAY
ENV DISPLAY ${DISPLAY}
RUN apt-get update && apt-get install -y apt-utils firefox curl python python3
CMD ["/bin/bash"]
I build everything and start the container with the following script
#!/bin/bash
docker-compose -f docker-compose3.yml build
docker-compose f docker-compose3.yml up
First problem is that the container just exit so I have to run it manually like this:
docker run -it myworkenv:latest3 /bin/bash
Running it this way, when I check in the container I cannot find the folder of the volume aka /tmp/.X11-unix
On my research I have found that I could launch the container with :
docker compose run -v /tmp/.X11-unix:/tmp/.X11-unix app
This time I explicitly specify the volume on the run command (I know I could have omitted it since it is already written in the docker-compose file but anyway). However when I jump on the container I can see the folder /tmp/.X11-unix but it is not shared with the host. In fact the files inside the folder in the host do not appear in the folder in the container.
I would appreciate any help on this matter.
Note 1: In order to get the DISPLAY env variable copied in the container I has to use ARG keyword because I couldn't get it when just using environment. For example the variable MYVAR is not set in the container. It is like if the sections environment and volume are simply ignored.