this post was submitted on 25 Feb 2024
151 points (91.3% liked)
Linux
48083 readers
749 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Docker is one of the container technologies
Containers vs Images
This is a very simplified explanation, which hopefully clears up for you. As with all simplifications, they aren't entirely correct.
Containers put processes, files, and networking into a space where they are secluded from the rest. You main OS is called the host and the container is called the guest. You can selectively share resources with the guest. To use an analogy, if you house were the computer with linux, if you took a room, put tools and resources for those tools into it, put workers into it, got them to start working and locked the door, they'd be contained in the room, unable to break out. If you want to give workers access to resources, you either a window, a corridor, or even a door depending on much access you want to give them.
Containers are created from an image. Think of it as the tools, resources, and configuration required every time you create a room in your house for workers to do a job. The woodworkers will need different tools and resources than say metalworkers.
Most images are stored on DockerHub. So when you do
docker pull linuxserver/sonarr
you download the image. When you dodocker run linuxserver/sonarr
you create a container from an image.Installation
You're on Cinnamon Mint which is linux distribution derived from another linux distribution called debian. You have to follow the installation instructions. Everything is there. If something doesn't work, it's most likely because you skipped a step. The most important ones are the post-installation steps:
Those are the most commonly missed steps. I've fallen for this trap too!
Local help
To use linux, you need to learn about ways to help yourself or find help. On linux, most well-written programs print a help. Simply running the command without any arguments most often output a help text --> running
docker
does so. If they don't, then the--help
flag often does -->docker --help
. The shorthand is-h
-->docker -h
.Some commands have sub commands e.g
docker run
,docker image
,docker ps
, ... . Those subcommands also take flags of which-h
and--help
are available.The help output is often not extensive and programs often have a manual. To access it the command is
man
-->man find
will output the manual for thefind
command. Docker doesn't have a local manual but an online one.For clarification when running a command there are different ways to interpret the text after the command:
Flags/Options
These are named parameters to the command. Some do not take input like
-h
and--help
which are called flags. Some do like--file /etc/passwd
and are often called options.Arguments
These are unnamed parameters and each command interprets them differently.
echo "hello world"
-->echo
is the command and"hello world"
is the argument. Some commands can take multiple argumentsRunning containers
Imperatively
As described above
docker run linuxserver/sonarr
runs an image in a container. However, it runs in the foreground (as opposed to the background in what is most often called a "daemon"). Starting in the foreground is most likely not how you want to run things as that means if you close your terminal, you end the process too. To run something in the background, you usedocker run --detatch linuxserver/sonarr
.You can pass options like
-v
or--volume
to make a file or folder from your host system available in the guest e.g-v /path/on/host:/tmp/path/in/guest
. Or-p
/--port
to forward a host port to a guest port e.g-p 8080:80
. That means if you access port8080
on your host, the traffic will be forwarded to port80
in the guest.These are imperatives as in you command the computer to do a specific action. Run that docker image, stop that docker container, restart these containers, start a container with this port forward and that volume with this user ...
Declaratively
If you don't want to keep typing the same commands, you can declare everything about your containers up front. Their volumes, ports, environment variables, which image is used, which network card/interface they have access to, which other network they share with other containers, and so on.
This is done with
docker-compose
ordocker compose
for newer docker versions (not all operating systems have the new docker version).This already a long text, so if you want to know more, the best resource is the docker compose manual and the compose file reference.
Hopefully this helped with the basics and understanding what you're doing. There are probably great video resources out there that explain it more didactically than I do with steps you can follow along.
Good luck!
CC BY-NC-SA 4.0
The word "guest" is generally used for virtual machines, not containers.
Can containers boot on their own? Then they are hosts, if not they are guests.
Unless there is some kind of mutual 50/50 cohabitation of userspace with two different pid1s
pid 1 left pid 1 right
@cypherpunks @onlinepersona
It depends what you mean by "boot". Linux containers are by definition not running their own kernel, so Linux is never booting. They typically (though not always) have their own namespace for process IDs (among other things) and in some cases process ID 1 inside the container is actually another systemd (or another init system).
However, more often PID 1 is actually just the application being run in the container. In either case, people do sometimes refer to starting a container as "booting" it; I think this makes the most sense when PID 1 in the container is systemd as the word "boot" has more relevance in that scenario. However, even in that case, nobody (or at least almost nobody I've ever seen) calls containers "guests".
As to calling containers "hosts", I'd say it depends on if the container is in its own network namespace. For example, if you run
podman run --rm -it --network host debian:bookworm bash
you will have a container that is in the same network namespace as your host system, and it will thus have the same hostname. But if you omit--network host
from that command then it will be in its own network namespace, with a different IP address, behind NAT, and it will have a randomly generated hostname. I think it makes sense to refer to the latter kind of container as a separate host in some contexts.