Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Tutorials»How to Export and Import Docker Containers

    How to Export and Import Docker Containers

    By RahulMarch 2, 20162 Mins Read

    In our previous tutorials you have learned about installation of Docker engine on CentOS/RHEL and Ubuntu operating system and pulled images from Docker hub. After that created containers with images. This tutorial will help you to export and import Docker containers and move them between hosts.

    Advertisement

    List Containers

    Fist list all containers on your system using below command. Using ps -a will list all containers (running and stopped) from your system.

    [email protected]:~# docker ps -a
    
    CONTAINER ID   IMAGE    COMMAND      CREATED       STATUS      PORTS  NAMES
    f2582758af13   ubuntu   "/bin/bash"  2 hours ago   Up 2 hours         ubuntu-web
    2b199b9976c4   centos   "/bin/bash"  3 days ago    Up 3 hours         centos-mysql
    

    Export Container

    Finally use the following command to export container named ubuntu-web (container id: f2582758af13) and make a zipped archive named ubuntu-web.tar.gz. Remember that export is used for making backup of docker containers (not images) in image format.

    # docker export ubuntu-web | gzip > ubuntu-web.tar.gz
    

    Import Container

    After exporting docker container on your system move it to remote server using scp or ftp. After that use below command on remote server to import Docker container on remote server with name ubuntu-web.

    # zcat ubuntu-web.gz | docker import - ubuntu-web
    

    The above command will create a docker image on your system. You can now launch a container from this image using below command.

    # docker run -i -t ubuntu-web /bin/bash
    

    containers Docker
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Understanding 2>&1 in Bash: A Beginner’s Guide

    How to Choose the Best Shebang (#!) for Your Shell Scripts

    Modulus Operator (%) in Bash

    Using Modulus Operator (%) in Bash

    View 7 Comments

    7 Comments

    1. alvianno wijaya on July 12, 2018 9:18 am

      hi

      Reply
    2. alvianno wijaya on July 12, 2018 8:57 am

      [email protected]:~# docker run -i -t klokantech/openmaptiles-server /bin/bash
      [email protected]:/#

      change [email protected]*** and how to hosting countainer???

      Reply
      • Amol on September 5, 2019 8:58 am

        If u want to change [email protected] then u can specify with command #docker run -it –hostname=anything-here repositorynamehere(ex:-ubuntu:latest) /bin/bash

        Reply
    3. Tomas on February 12, 2018 8:07 pm

      Hi
      I use docker run -d -p 63700:80 –name apachetest –volumes-from apache3 apache , and export to tar file.
      When I import to different server , I lost all of settings , how do I backup the container parameter?
      thanks.

      Reply
      • Amol on September 5, 2019 9:01 am

        docker run -it -d yourrepo or anything else u want to attach with command at last dont forget to use command
        # docker commit your repositorynamehere

        Reply
    4. Rigsworth on October 3, 2017 9:41 am

      This worked ok, but not all of the data has moved with the container.
      Do you have any further notes on how to copy underlying data?

      Reply
      • Rahul K. on October 9, 2017 9:23 am

        Have you attached any data volume to the container?

        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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