How to access volumes remotly

Hello everyone.
I’m begginer using docker on Ubuntu 18 and i have my first question:

Currently I have some volumes mounted in docker where if I need to access your files internally I just use the following command:

docker container exec -it ‘service’ bash

But I’d like to access those volumes remotely. I would like to know if this is possible like for example using a Tomcat where I want to upload my application doing deploy by FTP.

I hope everyone can understand my problem.

Mounting Volumes can be done when you run the container and is easy to do. here is a sample run command:

docker run --name YourNAME -d -it -v /localdir/:/containerdir containername /bin/sh

for example -v /My/HTMLdir:/var/apache/html/

There is a great free Docker training course here to help you when time permits

Hi Don!!
Thanks a lot for your guide. For sure i’ll check when possible.

About my question, i tried start my docker with this command bellow:

docker run -d -p 8080:8080 --restart always --name tomcat -it -v /My/HTMLdir:/var/apache/html/ tomcat:9.0

And worked very well. I was able to upload files on /My/HTMLdir directory and it was applied also inside /var/apache/html/.
But my real request is upload files inside this directory /usr/local/tomcat/webapps. This directory i can auto deploy application on Tomcat. So i tried to start my docker using the next command:

docker run -d -p 8080:8080 --restart always --name tomcat -it -v /Kvra/DeployTomcat:/usr/local/tomcat/webapps tomcat:9.0

But my Tomcat wasn’t able to access the Manager. Probably because /usr/local/tomcat/webapps isn’t the main directory of Tomcat, right? What can i do about this?

my guess is that the webapps are not in the local directory /Kvra/DeployTomcat directory already and the files that are part of apache in that container directory are not visable when you replace the /usr/local/tomcat/webapps folder.

You can try to this
docker run -d -p 8080:8080 --restart always --name tomcat -it -v /My/tempstore:/tempstore tomcat:9.0
then docker exec into the container
copy /usr/local/tomcat/webapps to /my/tempstore
then copy temptore files to /Kvra/DeployTomcat
then run
docker run -d -p 8080:8080 --restart always --name tomcat -it -v /Kvra/DeployTomcat:/usr/local/tomcat/webapps tomcat:9.0

1 Like

Hi Don,
I already deleted my first container to not make any conflicts with your new commands but how can i run the bellow command if i already created another container with your first command? --> docker run -d -p 8080:8080 --restart always --name tomcat -it -v /My/tempstore:/tempstore tomcat:9.0

root@lynx-o:/My/tempstore# docker run -d -p 8080:8080 --restart always --name tomcat -it -v /Kvra/DeployTomcat:/usr/local/tomcat/webapps tomcat:9.0

docker: Error response from daemon: Conflict. The container name “/tomcat” is already in use by container “ce7fe4aeb5aae7c4958b877b23fd6f28e2313e79def85b3c295961d1d7146d0a”. You have to remove (or rename) that container to be able to reuse that name.
See ‘docker run --help’.

My way of handling this is to --name tomcat -p 8080:8080 for one --name tomcat2 -p 8082:8080

either that or do a docker stop tomcat followed by a docker rm tomcat before doing step 2

Hope that helpos

But if i do this, i’ll remove the last Tomcat configured to use /My/tempstore:/tempstore
After this the manager of new Tomcat doesn’t work.

I’m confused now…

Hi Don,
I’m sorry!! The answer was i front of me.
The issue was exctly about the webapps are not in the local directory /Kvra/DeployTomcat directory already and the files that are part of apache in that container directory are not visable when you replace the /usr/local/tomcat/webapps folder.
So i just copied all the files inside this folder and mounted the container again.
Thanks a lot for your help!

1 Like