• 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 transfer the files between Linux containers and the host system on Ubuntu 21.04

  • 00:39 lsb_release -a
  • 00:53 lxc launch images:centos/8/amd64 test1
  • 01:29 lxc launch images:ubuntu/22.04/amd64 test2
  • 02:08 lxc list
  • 02:18 lxc exec test1 bash
  • 02:36 cat /etc/os-release
  • 02:45 exit
  • 03:00 lxc exec test2 bash
  • 03:15 lsb_release -a
  • 03:28 touch linuxhelp
  • 03:40 exit
  • 04:00 lxc file pull test2/root/linuxhelp /root
  • 04:21 ls -la linuxhelp
  • 04:37 lxc file push /root/linuxhelp test1/root/
  • 05:06 lxc exec test1 bash
  • 05:21 ls -la
{{postValue.id}}

To Transfer The Files Between Linux Containers And Host System On Ubuntu 21.04

Introduction:

Linux Containers provide OS-level virtualization through a virtual environment containing its own processes and network space, as well as resource isolation through control groups. LXC provides a userspace container object that provides full resource isolation and control for a system or an application based on these new functionalities.

Installation Procedure:

Step 1: Check the OS version by using the 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: Launch the Cent OS 8 container by using the below command

root@linuxhelp:~# lxc launch images:centos/8/amd64 test1
Creating test1
Starting test1

Step 3: Launch the Ubuntu 22.04 container by using the below command

root@linuxhelp:~# lxc launch images:ubuntu/22.04/amd64 test2
Creating test2
Starting test2 

Step 4: List the available Linux container by using the below command

root@linuxhelp:~# lxc list
+-------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| NAME  |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS |

+-------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| test1 | RUNNING | 10.241.214.182 (eth0) | fd42:d310:820b:2411:216:3eff:fe21:be8 (eth0)  | CONTAINER | 0         |
+-------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| test2 | RUNNING | 10.241.214.140 (eth0) | fd42:d310:820b:2411:216:3eff:fedc:6f81 (eth0) | CONTAINER | 0         |
+-------+---------+-----------------------+-----------------------------------------------+-----------+-----------+

Step 5: Login to the test1 container’s Shell by using the below command

root@linuxhelp:~# lxc exec test1 bash

Step 6: Check the OS version by using the below command

[root@test1 ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"

Step 7: Exit from the test1 container

[root@test1 ~]# exit
exit

Step 8 Login to the test2 container’s Shell by using the below command

root@linuxhelp:~# lxc exec test2 bash 

Step 9: Check the OS version by using the below command

root@test2:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu Jammy Jellyfish (development branch)
Release:	22.04
Codename:	jammy

Step 10: Create a file named linuxhelp by using the below command

root@test2:~# touch linuxhelp

Step 11: Exit from the test1 container

root@test2:~# exit
exit

Step 12: Pull the file from container to host by using the below command

root@linuxhelp:~# lxc file pull test2/root/linuxhelp /root

Step 13: List the copied file by using the below command

root@linuxhelp:~# ls -la linuxhelp 
-rw-r--r-- 1 root root 0 Dec 31 15:10 linuxhelp

Step 14: Pull the file from host to container by using the below command

root@linuxhelp:~# lxc file push /root/linuxhelp test1/root/

Step 15: Login to the test2 container’s Shell by using the below command

root@linuxhelp:~# lxc exec test1 bash

Step 16: List the copied file by using the below command

[root@test1 ~]# ls -la
total 8
dr-xr-x---  2 root root   9 Dec 31 09:42 .
drwxr-xr-x 18 root root  23 Dec 31 09:35 ..
-rw-------  1 root root  26 Dec 31 09:38 .bash_history
-rw-r--r--  1 root root  18 May 11  2019 .bash_logout
-rw-r--r--  1 root root 176 May 11  2019 .bash_profile
-rw-r--r--  1 root root 176 May 11  2019 .bashrc
-rw-r--r--  1 root root 100 May 11  2019 .cshrc
-rw-r--r--  1 root root 129 May 11  2019 .tcshrc
-rw-r--r--  1 root root   0 Dec 31 09:42 linuxhelp

By this to transfer the files between Linux containers and host system on Ubuntu 21.04 has been completed.

Tags:
jackson
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

How to copy a file from the container to the Host system?

A

To copy a file from the container to the Host system by using the following command lxc file pull /

Q

How to copy a file from the host system to the container?

A

To copy a file from host system to the container by using the following command lxc file push /

Q

What are the two types of containers?

A

LXC has two types of containers, privileged containers, and unprivileged containers

Q

What is the location of LXC storage containers?

A

LXC storage containers are located under /var/lib/lxc for the root user.

Q

How to list only active containers?

A

To list only active containers use command

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 Lucas ?
Various options in Top command

Am using Top command only to view the load average, what are the various options in Top command..??

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.