Sharing a folder from a docker container

Is there a way to share a folder with a docker container for hosting?

For example, I have a tomcat inside the docker container, and I want it to be visible from the outside.

If I do this volumes: - / opt / tomcat: / opt / tomcat

I get an error in the container: "There is no such file or directory /opt/tomcat/bin/catalina.sh"

+5
source share
1 answer

I do not think Docker allows you this. This command will mount your host folder in the container, so your files in the container are no longer visible.

Two options:

  • You can access container files using this trick (GitHub issue) : sudo ls /proc/$(docker inspect --format {{.State.Pid}} YOUR_CONTAINER_NAME)/root . You need root privileges to access them, or you can use bindfs to match the root user with your username (see Same thread).

  • Create a new volume, copy the files you need and install it inside the container in the right place.

+1
source

Source: https://habr.com/ru/post/1263261/


All Articles