Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»General Articles»Copying files from Host to Docker Container

    Copying files from Host to Docker Container

    By RahulNovember 22, 20221 Min Read

    When running containers, you may have files that you need to copy from the host machine into the container. This can be for a number of reasons, such as configuration files that are specific to your environment and cannot be sourced from standard locations or if you want to leverage a private registry like Atlas as part of your workflow. If this sounds like something you need in your workflow, continue reading this blog post to learn more about how it’s done! There are multiple ways of doing this but the following is the most common. Keep reading to learn more…

    Advertisement

    Copy files to docker container from host

    The docker cp command is used to copy files to/from the docker container and host system. See the following example:

    docker cp data.txt CONTAINER_ID:/var/files/data.txt
    

    Change CONTAINER_ID with the read id of a running container. The above command will copy the data.txt file from the host machine to the docker container under the /var/files directory.

    Copy files from docker container to host

    The following command will copy /var/files/data.txt file from the docker container to the host machine.

    docker cp CONTAINER_ID:/var/files/data.txt data.txt 
    

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    sleep Command in Linux with Examples

    20 Basic Linux Commands for the Beginners (Recommended)

    tail Command in Linux with Examples

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • sleep Command in Linux with Examples
    • 20 Basic Linux Commands for the Beginners (Recommended)
    • tail Command in Linux with Examples
    • What is a Orphan Process in Unix/Linux
    • How To Display Warning Message to Unauthorized SSH Access
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.