• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Export and Import Docker Container on Ubuntu 21.04

  • 00:31 lsb_release -a
  • 00:42 docker pull ubuntu
  • 01:13 docker images
  • 01:22 docker run -dit ubuntu
  • 01:39 docker ps
  • 02:02 docker exec -it recursing_liskov /bin/bash
  • 02:22 apt update
  • 02:40 apt install tree -y
  • 02:55 exit
  • 03:04 docker ps
  • 03:10 docker export --output="tree.tar" recursing_liskov
  • 03:52 ls -la
  • 04:05 docker import tree.tar
  • 04:20 docker images
  • 04:30 docker run -it 393a31a43b09 /bin/bash
  • 04:46 apt list --installed | grep tree
{{postValue.id}}

To Export and Import Docker Container on Ubuntu 21.04

Introduction:

Docker is a platform as a service that delivers software in containers using OS-level virtualization, which allows you to build, test, and deploy applications quickly and easily.

Installation Procedure:

Step 1: Check the OS version by using below Command

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 21.04
Release:	21.04
Codename:	hirsute

Step 2: Pull the Ubuntu Docker Image from Docker Hub BY using the below command

root@linuxhelp:~# docker pull ubuntu 
Using default tag: latest
latest: Pulling from library/ubuntu
08c01a0ec47e: Pull complete 
Digest: sha256:669e010b58baf5beb2836b253c1fd5768333f0d1dbcb834f7c07a4dc93f474be
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest

Step 3: List the Docker Images by using the below command

root@linuxhelp:~# docker images 
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
ubuntu       latest    54c9d81cbb44   13 days ago   72.8MB

Step 4: Run a Container from Ubuntu Docker Image by using the below command

root@linuxhelp:~# docker run -dit ubuntu 
8cae3796c71227f24e494526fa32b8b422eb9f842d5c94fa59fcb32001ff66de

Step 5: Check the Running Containers by using the below command

root@linuxhelp:~# docker ps 
CONTAINER ID   IMAGE     COMMAND   CREATED         STATUS         PORTS     NAMES
8cae3796c712   ubuntu    "bash"    8 seconds ago   Up 6 seconds             recursing_liskov

Step 6: Login to the Container Shell by using the below command

root@linuxhelp:~# docker exec -it recursing_liskov /bin/bash 

Step 7: Update the APT source List by using the below command

root@8cae3796c712:/# apt update 
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Fetched 21.0 MB in 6s (3519 kB/s)                      
Reading package lists... Done
Building dependency tree       
Reading state information... Done
9 packages can be upgraded. Run 'apt list --upgradable' to see them.

Step 8: Install tree Package for testing purpose by using the below command

root@8cae3796c712:/# apt install tree -y 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  tree
0 upgraded, 1 newly installed, 0 to remove and 9 not upgraded.
Need to get 43.0 kB of archives.
After this operation, 115 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 tree amd64 1.8.0-1 [43.0 kB]
Fetched 43.0 kB in 1s (70.7 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package tree.
(Reading database ... 4127 files and directories currently installed.)
Preparing to unpack .../tree_1.8.0-1_amd64.deb ...
Unpacking tree (1.8.0-1) ...
Setting up tree (1.8.0-1) ...

Step 9: Exit from the Container

root@8cae3796c712:/# exit 
exit

Step 10: Check the Running Containers by using the below command

root@linuxhelp:~# docker ps 
CONTAINER ID   IMAGE     COMMAND   CREATED              STATUS              PORTS     NAMES
8cae3796c712   ubuntu    "bash"    About a minute ago   Up About a minute             recursing_liskov

Step 11: Export the Running Container as tar file by using the below command

root@linuxhelp:~# docker export --output="tree.tar" recursing_liskov

Step 12: List the exported Image by using the below command

root@linuxhelp:~# ls -la 
total 106540
drwx------  4 root root      4096 Feb 16 04:34 .
drwxr-xr-x 20 root root      4096 Jan 15 02:16 ..
-rw-------  1 root root      1307 Jan 27 15:29 .bash_history
-rw-r--r--  1 root root      3106 Aug 15  2019 .bashrc
drwx------  3 root root      4096 Jan 19 23:33 .cache
-rw-r--r--  1 root root       161 Sep 16  2020 .profile
drwxr-xr-x  3 root root      4096 Jan 15 02:24 snap
-rw-------  1 root root 109064192 Feb 16 04:34 tree.tar
-rw-------  1 root root       767 Jan 15 02:19 .viminfo

Step 13: Import the Exported Container, The Exported Container is imported as Docker Image then need to run the Containers from the Image

root@linuxhelp:~# docker import tree.tar 
sha256:393a31a43b0904b8c0b6e2b7393bdc3806e4bdc0da81d183b85b8dbf3c50644d

Step 14: List the Docker Images by using the below command

root@linuxhelp:~# docker images 
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
<none>       <none>    393a31a43b09   6 minutes ago   107MB
ubuntu       latest    54c9d81cbb44   13 days ago     72.8MB

Step 15: Run a Container from the Imported Docker Image by using the below command

root@linuxhelp:~# docker run -it 393a31a43b09 /bin/bash 

Step 16: Check the Package installed before exporting by using the below command

root@fe34a3a35799:/# apt list --installed | grep tree 


WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

tree/focal,now 1.8.0-1 amd64 [installed]

with this, the process of How to Export and Import Docker Container on Ubuntu 21.04 has comes to an end.

Tags:
jayce
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

How to Rename the Docker image?

A

To Rename the Docker image use command myname/server:latest>

Q

How to Export the Docker Container?

A

To Export the Docker Container use command

Q

How to Import the Docker Container?

A

To Import the Docker Container use the command

Q

What happens while Importing the Exported Docker Container?

A

Exported Docker Container will be Imported as a Docker Image, not Container, so need to run as Container from Imported Image.

Q

What are Kubernetes and Docker?

A

Kubernetes is open-source orchestration software that provides an API to control how and where those containers will run.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Isaiah ?
What is the use of SUID & SGID commands

How to set the special permissions to the files and folders using SUID and SGID commands...

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.