Docker Quick Start: Why? What are containers for? Hardware?
What are Docker containers?
Docker containers are small isolated program units that can be started independently of the operating system on almost any PC or server. The user interface of a container is usually provided in the form of a web service and can thus be accessed via an address in the browser. Calling from a PC, smartphone or tablet is done via any browser and therefore does not require any additional installed software or app.
How can a Docker container be started?
To start a container, it is sufficient to specify an image in the form of manufacturer/imagename. This is made possible by the Docker Registry, a kind of library for containers. After installation, Docker is connected to the official online Docker Registry: Docker Hub, which means that specifying the imagename is enough to download and launch the container: no matter what hardware, no matter what operating system, and no matter what other programs have already been installed on the system: Due to the encapsulation, the containers are isolated and independent and contain all the dependencies necessary for operation.
Command for starting a container
In detail, the startup process of a container in the terminal looks like this:
docker run docker/getting-started
The "docker run" command downloads the "getting-started" container from the "docker" vendor and starts it:
C:\Users\LiBe>docker run -p 8080:80 docker/getting-started
Unable to find image 'docker/getting-started:latest' locally
latest: Pulling from docker/getting-started
...
2023/05/28 18:30:23 [notice] 1#1: start worker processes
The parameter -p 8080:80 publishes port 80 and makes it available through localhost and port 8080:
How to access the user interface of a container?
A Docker service is usually accessed via a provided web service. Typically, the web server provided by a container can be accessed via the browser with localhost and a port specified when starting the container: as an example: http://localhost:8080.
Prerequisite: almost any PC or server, operating system and the Docker installation.
Any computer or mini-PC with x68-64 architecture can be used as hardware for starting the containers, see: Home Server. Depending on which operating system is used, the actual Docker installation differs:
- Docker installation: Linux: Docker Engine 👍(Recommended variant).
- Docker installation: Windows: Docker Desktop (For testing and demo purposes).
Docker containers require a Linux kernel, so container scan likely be run with a Linux distribution - unlike Windows - with less overhead.
Multiple containers for a given service -> Docker Compose.
Docker containers provide network services, as an example a web server or database. Certain web applications require multiple containers to run. The launch of multiple containers and their access to and among each other can be specified using Docker Compose and a simple test file: docker-compose.yml.
The previously mentioned container: "getting-started" can be defined using a docker-compose.yml file as follows:
Text file named "docker-compose.yml".
Content:
services:
app:
image: docker/getting-started
ports:
- 8080:80
If a text file is populated with this content, all services mentioned in the file can be started from its folder with one command: "docker compose up"
root@server:~/# docker compose up
Creating network "test_default" with the default driver
Creating test_app_1 ... done
Attaching to test_app_1
To start more services from the text file, they can be added as additional services:
services:
app:
image: docker/getting-started
ports:
- 8080:80
app2:
image: docker/getting-started
ports:
- 8081:80
Step by step guide published as YouTube video
For secure publishing of web services over the Internet, see also: secure https connection: Traefik Reverse Proxy + Let's Encrypt.
Docker-Webservices, examples
Here is a list of web services I have tested so far:
{{percentage}} % positive