Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Tutorials»How to Export and Import Docker Containers

    How to Export and Import Docker Containers

    RahulBy 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.

    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
    Previous ArticleHow to Remove Docker Images and Containers
    Next Article How to Move Docker Images between Hosts

    Related Posts

    How to Correctly Set the $PATH variable in Bash

    2 Mins Read

    How To Create and Run a Flask Application Using Docker

    4 Mins Read

    How To Install Docker on Ubuntu 22.04

    3 Mins Read

    How to run “npm start” through Docker

    Updated:July 2, 20222 Mins Read

    What is the /etc/aliases file

    2 Mins Read

    What is the /etc/nsswitch.conf file in Linux

    2 Mins Read

    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

    Recent Posts
    • How to Import GPG Keys on Ubuntu & Debian (without apt-key)
    • How To Install Google Chrome On macOS
    • How to Install Minecraft on Ubuntu 22.04 & 20.04
    • Running a Cron job every Sunday (Weekly)
    • Running Multiple Commands At Once in Linux
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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