Dynamically add volumes to the running containers

Hi All,

This is my first post to get some help on docker issue that my customer is facing though I am not expert in docker, but I did good amount of research before posting this.

Issue: My customer was claiming that previously he was able to SSH to docker host (Ubuntu) on port 2222 using a SSH GUI client and then browse to /var/atlassian/jira/import to import files from his local PC so that those files will be uploaded to docker container (there must be a bind volume) then he can login to the application to see those files were there for other purposes. When I looked at the issue first time, I could not see PORT 2222 while executing “docker port containername” or “docker ps” . Only 8080 port was listed there. Another thing is, when I asked to run inspect command to get mount details, they provided below;

"Mounts": [
            "Name": "server_config",
            "Source": "/var/lib/docker/volumes/server_config/_data",
            "Destination": "/opt/atlassian/jira/conf",
            "Driver": "local",
            "Mode": "z",
            "RW": true,
            "Propagation": "rprivate"
            "Name": "server_logs",
            "Source": "/var/lib/docker/volumes/server_logs/_data",
            "Destination": "/opt/atlassian/jira/logs",
            "Driver": "local",
            "Mode": "z",
            "RW": true,
            "Propagation": "rprivate"
            "Name": "server_data",
            "Source": "/var/lib/docker/volumes/server_data/_data",
            "Destination": "/var/atlassian/jira",
            "Driver": "local",
            "Mode": "z",
            "RW": true,
            "Propagation": "rprivate"

“HostConfig”: {
“Binds”: [
“ContainerIDFile”: “”,

The above seems to be data volumes. I have a similar docker image with me and replicated issue locally. But when I recreate docker run with -v and -p options, all I can see is a new application installation comes up (which means changes I made to original image/data or lost). Then I see docker commit to commit container to an image, but this won’t include the data from volumes. I see the data is now in, /var/lib/docker/volumes/server_data/_data. Can I dynamically add new mounts or expose ports to the running container?

How can I resolve this issue so the docker container preserve the data as is and be able to SSH on port 2222 to get to docker host and copy files to the container? Currently docker cp command works but wanted to do this through a SSH client.

Any help or suggestions would be greatly appreciated.


i do not believe that you can effectively do docker CP after docker build.

you CAN use the OS copy command (also called cp) to copy files from an existing volume (mount) into the container at some other location. in this case NEW data could be added to the volume before the os cp comand is issued… (create a folder on the mounted volume, pass the folder name to the os cp command, erase the folder when done)…

as you have seen mount located data is NOT saved into the image created by docker commit…

Thanks sdetweil for reply. This is what I understand from your reply:
Do a commit on current container (new image will be created)
Start / run a new container from new image using -v /var/lib/docker/volumes/server_data/_data:/tmp/data and -p 2222:22
docker exec to get into the newly created container and copy or overwrite data from volume (/tmp/data) to another volume created by docker.
stop container and start again (since the new data was in place will directly go in application rather than application installation wizard).

Please correct me if its wrong.

doesn’t have to be a ‘volume created by docker’… just some folder location…

in one of my solutions I untar a big file to the root of the container (/) and it creates the /opt folder tree