• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Export and Import Docker Containers

Written by Rahul, Updated on March 2, 2016

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

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

7 Comments

  1. Avatar alvianno wijaya Reply
    July 12, 2018 at 9:18 am

    hi

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

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

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

    • Avatar Amol Reply
      September 5, 2019 at 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

  3. Avatar Tomas Reply
    February 12, 2018 at 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.

    • Avatar Amol Reply
      September 5, 2019 at 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

  4. Avatar Rigsworth Reply
    October 3, 2017 at 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?

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

      Have you attached any data volume to the container?

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy