LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Containers
User Name
Password
Linux - Containers This forum is for the discussion of all topics relating to Linux containers. Docker, LXC, LXD, runC, containerd, CoreOS, Kubernetes, Mesos, rkt, and all other Linux container platforms are welcome.

Notices


Reply
  Search this Thread
Old 12-10-2018, 05:09 AM   #1
sreyan32
Member
 
Registered: Jan 2015
Posts: 52

Rep: Reputation: Disabled
How does Docker implement networking and installation?


If Dockers are nothing but namespaced processes on the system then how does it handle the following:
  • If I install a software component within Docker does it get installed in the host operating system as well? Intution says thats the case, since if they are jailed processes.
  • How does docker namespace the networks? How does it handle networking?
 
Old 12-10-2018, 05:45 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,692

Rep: Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274
you need to go to the official docker site and read the documentation. You will find detailed answers for every questions.
https://medium.com/@kasunmaduraeng/d...s-dece27c209c7
 
Old 12-10-2018, 06:03 AM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by sreyan32 View Post
If Dockers are nothing but namespaced processes on the system then how does it handle the following:
  • If I install a software component within Docker does it get installed in the host operating system as well? Intution says thats the case, since if they are jailed processes.
  • How does docker namespace the networks? How does it handle networking?
Docker containers don’t have a separate operating system. Programs running in a Docker container use the container host’s OS. In case you mean the filesystem: There are several filesystem implementations, including a simple filesystem subtree on the host. See https://docs.docker.com/storage/.

Docker uses the kernel’s network namespace feature.

How it handles networking? As pan64 says, read Docker documentation. In case you don’t find it: https://docs.docker.com/network/

Last edited by berndbausch; 12-10-2018 at 06:09 AM.
 
Old 12-10-2018, 08:44 AM   #4
sreyan32
Member
 
Registered: Jan 2015
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
Docker containers don’t have a separate operating system. Programs running in a Docker container use the container host’s OS. In case you mean the filesystem: There are several filesystem implementations, including a simple filesystem subtree on the host. See https://docs.docker.com/storage/.

Docker uses the kernel’s network namespace feature.

How it handles networking? As pan64 says, read Docker documentation. In case you don’t find it: https://docs.docker.com/network/

I will check the networking part. But can you tell me what happens when you install a software package inside a container? Does that affect the host system as well?
 
Old 12-10-2018, 09:06 AM   #5
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by sreyan32 View Post
I will check the networking part. But can you tell me what happens when you install a software package inside a container? Does that affect the host system as well?
Sure it does. Disk space is used. IO is generated. CPU is used. Processes in the container show up in the host’s process table. There is a wall or a hedge around the container’s resources, but the resources come from the host.
 
Old 12-10-2018, 09:15 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,692

Rep: Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274
it is explained on the net, you will find the answers.
docker is an isolation therefore the processes inside the docker (hopefully) will not be able to go outside or into another docker. But from the host you will be able to see inside.
 
Old 12-11-2018, 11:11 AM   #7
sreyan32
Member
 
Registered: Jan 2015
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
it is explained on the net, you will find the answers.
docker is an isolation therefore the processes inside the docker (hopefully) will not be able to go outside or into another docker. But from the host you will be able to see inside.
Let me understand this via a simple example, lets say I setup a container, and I start a bash shell within that container. Now there are a couple of things I cant understand
  • Lets say I do an apt-get install python3 in the container. Does that install python3 in the host OS as well? That is if I exit the shell of the container and I type python on the host bash shell will I get the python REPL? My thinking says that I should, if not I am really interested in knowing how docker separates that.
  • When for example I launch another process within a Docker, then does it show up as another process in the ps table?
  • How can you run a RHEL Docker within an Ubuntu OS? If so how? The RHEL OS has a completely different format, even when it comes to binaries I think. How do you support that in another OS?

The believe the main reason for this confusion is because I am unable to understand why Docker is not a VM. I have read about namespaces but it doesn't explain a lot of the things Docker is able to pull off like "magic".
 
Old 12-11-2018, 11:13 AM   #8
sreyan32
Member
 
Registered: Jan 2015
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
Sure it does. Disk space is used. IO is generated. CPU is used. Processes in the container show up in the host’s process table. There is a wall or a hedge around the container’s resources, but the resources come from the host.
Does that software become a part of the host OS? That is in case of Ubuntu does it become a part of the host apt cache? If I do an apt-get remove from the host then will I be able to remove it from the system?
 
Old 12-11-2018, 11:27 AM   #9
notKlaatu
Senior Member
 
Registered: Sep 2010
Location: Lawrence, New Zealand
Distribution: Slackware
Posts: 1,077

Rep: Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732
When you install something from within a container, the package is installed in the local filesystem for the container ("inside" the container). So if you install Python3 in a container, then the container has Python3 but your host OS does not have access to Python3.

I don't use Docker, but I do use open source containers, so here's an example that applies to both:

Attach to the container:

Code:
$ sudo lxc-attach --name ubuntubox
Install Python3:

Code:
ubuntubox~$ sudo install python3
(...)
ubuntubox~$ python3 --version
python 3.6.7
Leave the container and try to use Python3 in the host:

Code:
ubuntubox~$ exit
$ python3
bash: python3 command not found
Go back into the container and try to use Python3:

Code:
$ sudo lxc-attach --name ubuntubox
ubuntubox~$ python3 --version
python 3.6.7
You can try this yourself.

Here's a great article introducing how containers work:

https://opensource.com/article/18/11...nux-containers
 
Old 12-11-2018, 03:53 PM   #10
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by sreyan32 View Post
Does that software become a part of the host OS? That is in case of Ubuntu does it become a part of the host apt cache? If I do an apt-get remove from the host then will I be able to remove it from the system?
No. Software goes to the container’s filesystem, which can be implemented as a filesystem subtree on the host or in other ways. See http://docker.com/storage for details.
 
Old 12-11-2018, 04:02 PM   #11
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by sreyan32 View Post
Let me understand this via a simple example, lets say I setup a container, and I start a bash shell within that container. Now there are a couple of things I cant understand
  • Lets say I do an apt-get install python3 in the container. Does that install python3 in the host OS as well? That is if I exit the shell of the container and I type python on the host bash shell will I get the python REPL? My thinking says that I should, if not I am really interested in knowing how docker separates that.
  • When for example I launch another process within a Docker, then does it show up as another process in the ps table?
  • How can you run a RHEL Docker within an Ubuntu OS? If so how? The RHEL OS has a completely different format, even when it comes to binaries I think. How do you support that in another OS?
Yes, processes run on the host and are visible there. You can kill them, for example.
You can run RHEL by copying all the files necessary for RHEL to the host.
Quote:
The believe the main reason for this confusion is because I am unable to understand why Docker is not a VM. I have read about namespaces but it doesn't explain a lot of the things Docker is able to pull off like "magic".
It’s not a VM because it doesn’t create virtual hardware and doesn’t run a separate kernel. Contained processes use the host’s resources. Processes in a VM run on virtual CPUs, virtual memory and access virtual devices. A VM runs - it uses CPU even when idle. A container doesn’t “run” at all. It’s a hedge around the software inside it. You can look through the hedge from outside, but not from inside.

If you are still confused, name some of the magic you allude to. We can try to explain how it’s done.
 
Old 12-13-2018, 02:30 PM   #12
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by sreyan32 View Post
If Dockers are nothing but namespaced processes on the system then how does it handle the following:
  • If I install a software component within Docker does it get installed in the host operating system as well?
In the container? no. Sorry, your intuition is "off"
https://docs.docker.com/get-started/part2/
Quote:
Originally Posted by sreyan32 View Post
How does docker namespace the networks? How does it handle networking?[/LIST]
https://docs.docker.com/network/

Have fun!

Last edited by Habitual; 12-13-2018 at 02:31 PM.
 
  


Reply

Tags
docker


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to install Docker and run Docker containers on Fedora 25 LXer Syndicated Linux News 0 12-07-2016 12:24 AM
LXer: Canonical and Docker Partner to Distribute Docker Releases as Snaps on Ubuntu LXer Syndicated Linux News 0 12-03-2016 09:57 PM
LXer: Docker Part 4: building and publishing custom docker images LXer Syndicated Linux News 0 04-08-2016 01:30 PM
LXer: Docker Engine 1.6 Debuts Alongside Docker Registry 2.0 and Compose 1.2.0 LXer Syndicated Linux News 0 04-17-2015 09:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Containers

All times are GMT -5. The time now is 06:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration