Attempting to copy files from host to docker container using “docker cp” does nothing

  • I have OMV installed with docker and portainer.

    I am trying to launch a minecraft server and copy my already existing world and server.properties from another server to it.


    I connect to my Minecraft server container using Portainer's console option and run "ls" to see all the files present. After confirming everything is at the root I run "rm -rf world" to delete the "world" directory and all its contents and then run "rm server.properties".


    Then I connect to OMV using SSH and run the following commands:

    all of them complete immediately with no message and have no effect.


    I test if they are successful by running "ls" on the Minecraft_server container through Poratiner's console option and see no "world" directory or "server.properties" file or anything after my deletions.


    What am I doing wrong for the copying to do nothing?

  • I've never used docker cp.. so can't say anything on that.


    What few times I've needed to do this, I just use the regular cp command and it seems to be fine (You might need to be root)


    cp /path/to/source /path/to/containers/Container_ID/


    Do you know where I can find where Docker stores the containers?

    • Official Post

    Do you know where I can find where Docker stores the containers?

    If you didn't set it up a custom path in the omv-extras plugin... it's in /var/lib/docker


    Note: If you have a small OS drive, or if you're anticipating a lot of space being used on a medium sized OS drive (Plex, Emby, Jellyfin, maybe your Minecraft server, I don't know)... it might behoove you to stop now and get your containers off your OS drive and onto one of your storage drives (which are typically much larger)... especially since you don't have much set up yet.

  • If you didn't set it up a custom path in the omv-extras plugin... it's in /var/lib/docker


    Note: If you have a small OS drive, or if you're anticipating a lot of space being used on a medium sized OS drive (Plex, Emby, Jellyfin, maybe your Minecraft server, I don't know)... it might behoove you to stop now and get your containers off your OS drive and onto one of your storage drives (which are typically much larger)... especially since you don't have much set up yet.


    Thank you, that is good advice!

    Final question - how to identify the correct path to copy the files to?

    I.e. how to identify the container, because I see several in /var/lib/docker, including some folders "overlay2" and "volumes" that seem like they could be holding my server files.

    • Official Post

    Thank you, that is good advice!

    Final question - how to identify the correct path to copy the files to?

    I.e. how to identify the container, because I see several in /var/lib/docker, including some folders "overlay2" and "volumes" that seem like they could be holding my server files.

    Again.. *typically*... The easiest way to do this... you'll need to a little comfortable with command line which I'm assuming you are given your previous posts


    Create a folder called "Containers" in the OMV webUI (this folder shouldn't be under any other folder, etc.. as it will start jacking up permissions for everything in that folder).. basically, make it it's own folder. Make sure you know the absolute path to this folder (/srv/dev-disk.../)


    Stop docker.. either in the webUI or via command line ( systemctl stop docker)


    Make sure docker is stopped.. again if the webUI shows it stopped, or systemctl status docker . That command should show docker is "inactive" at the top.. Cntrl + c to get back to a prompt.


    mv /var/lib/docker /absolute_path/to/Containers . That will move your current /var/lib/docker folder to the location you just created in the webUI


    cd /absolute_path/to/Containers and if you ls , you should see a folder called "docker"


    Go to the omv-WebUI, click omv-extras and click the docker tab. The path at the top (which right now is likely /var/lib/docker)... change that to the absolute path of the Containers folder you created and save (note: you should not need to add docker to the end, just to Containers)


    Restart docker... either in the webUI, or via systemctl start docker


  • Thank you for the detailed explanation! :)


    But I think you misunderstood me. I think you explained how to move where docker stores its containers (which is very useful) but I was asking how to identify the folder which holds the files for a certain container, i.e. how to know where to "cp" my world.

    • Official Post

    Thank you for the detailed explanation! :)


    But I think you misunderstood me. I think you explained how to move where docker stores its containers (which is very useful) but I was asking how to identify the folder which holds the files for a certain container, i.e. how to know where to "cp" my world.

    My bad, misunderstanding.


    docker ps -a

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!