Alpine linux docker установка

How to install docker & docker-compose on Alpine Linux

In this post, we’ll show how to install docker-compose (and the docker backend) on Alpine Linux.

Step 1: Enable the apk community repository

Edit the repository config as root using

It should look like this (the exact URLs will vary according to your selected mirror)

#/media/cdrom/apks http://ftp.halifax.rwth-aachen.de/alpine/v3.13/main #http://ftp.halifax.rwth-aachen.de/alpine/v3.13/community #http://ftp.halifax.rwth-aachen.de/alpine/edge/main #http://ftp.halifax.rwth-aachen.de/alpine/edge/community #http://ftp.halifax.rwth-aachen.de/alpine/edge/testing

Now find the line that ends in /community and does NOT end with /edge/community . Typically, this is the second line in the file:

#http://ftp.halifax.rwth-aachen.de/alpine/v3.13/community

Navigate to this line by using the arrow keys, press the Insert key in order to activate Editing.

Then remove the # at the beginning of the line. The resulting file should look like this:

#/media/cdrom/apks http://ftp.halifax.rwth-aachen.de/alpine/v3.13/main http://ftp.halifax.rwth-aachen.de/alpine/v3.13/community #http://ftp.halifax.rwth-aachen.de/alpine/edge/main #http://ftp.halifax.rwth-aachen.de/alpine/edge/community #http://ftp.halifax.rwth-aachen.de/alpine/edge/testing

Now save the file an exit the editor by pressing the Esc key, entering :wq and pressing enter.

Step 2: Install docker & docker-compose

Now we’ll fetch the package lists using

After that, we can install docker and docker-compose using

apk add docker docker-compose

Step 3: Enable docker daemon autostart & start docker daemon

Enable autostart on boot using

rc-update add docker default

and then start docker using

If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow

Источник

How to Install and Use Docker on Alpine Linux

Docker is a popular open-source containerization platform that makes it possible for developers to build, ship, and deploy their applications inside isolated environments called containers. Unlike virtual machines, containers are lightweight environments that ship with all the libraries, dependencies, and files required by an application to run.

Читайте также:  Build csproj on linux

In this guide, we will demonstrate how to install Docker on Alpine Linux.

Installing Docker on Alpine Linux

To start off, refresh or update the local package repositories using the following apk command.

To install docker and docker-compose from the Alpine Linux repositories, execute the command:

# apk add docker docker-compose

This installs docker and docker-compose alongside other additional packages, libraries, and dependencies.

Install Docker in Alpine Linux

So far, Docker is already installed. However, it does not start automatically. Therefore, enable the Docker daemon to start on boot time.

# rc-update add docker # service docker start

To confirm the version of Docker installed, run the command:

The output provides a wealth of information such as Docker, API and Go versions, and OS architecture just to mention a few.

Here is a summary of the output.

Check Docker Version in Alpine Linux

Testing Docker on Alpine Linux

To start using Docker, you need to add the regular user to the docker group as shown.

To test if Docker is actually working, we will pull a hello-world image from the Docker hub and run a container from the image.

To do this, run the command:

The command displays the Hello from Docker! message and provides you with the steps it took to print the message to the terminal.

Run Docker in Alpine Linux

Now let us try something more ambitious. We will pull a Debian image from the Docker hub as follows:

This pulls the latest Debian image.

Docker Pull Debian Image

To confirm the images residing on your system run:

The output tells us that we have two images – the hello-world and the debian images.

List Docker Images

To create a container from the Debian image and access the shell, we will run the command:

$ docker run -it debian /bin/bash

From here, you run commands on the shell just as you would on an actual Debian system. For example, you can check the version of Debian as follows:

Check Debian Version

To exit the container, run the command:

To view currently running containers, execute:

To list all containers including those which have exited after running run:

List Docker Containers

This wraps up our guide for today. In this guide, you have learned how to install Docker on Alpine Linux.

Читайте также:  Ubuntu linux руководство пользователя

Источник

How to Install Docker on Alpine Linux

Docker is a top-rated open-source containerization platform to run the virtualized lightweight machines without hassle. It has containers that are lightweight, unlike virtual machines that ship with all the files, dependencies, and libraries that needed to run.

Alpine Linux is known for its performance, security, and lightweight features. It is used to build the containers using various images which are available on the Docker Hub. However, you must install Docker to perform the various tasks in your system. In this short guide, we will show how to install Docker on Alpine Linux by following a few steps.

How to Install Docker on Alpine Linux

1. First of all, refresh the cache repository and install the latest one by running the following command:

2. Docker packages come pre-installed in the Alpine Linux repository, so you don’t need to add and do anything extra to it. Install the required package to install Docker using the apk manager.

The previous command adds the packages, dependencies, etc., associated with Docker and installs Docker in the system.

3. By default, Docker does not start automatically. Hence, it must be manually invoked after each boot through this command:

4. Start Docker with the help of the following command:

5. Moreover, you can check the Docker version that is installed in your system:

As you can see, the output of the previous command gives you the information like docker, Go and API version, etc.

6. You can check that the Docker that is installed by you is working properly by running the following command:

If your output is similar to the previous image, your Docker is working properly.

Conclusion

This is all you need to know to install Docker on Alpine Linux. Although Docker already comes in Alpine Linux, you must install it to work on it. Docker is an amazing tool that can make it easier for users to develop and run the applications through containers. If you are a developer, install Docker on your Alpine Linux machine.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.

Читайте также:  Увеличить размер папки linux

Источник

Docker

The Docker package is in the ‘Community’ repository. See Repositories how to add a repository.

Connecting to the Docker daemon through its socket requires you to add yourself to the `docker` group.

To start the Docker daemon at boot, see Alpine_Linux_Init_System.

rc-update add docker default service docker start

Docker rootless

Docker rootless allows unprivileged users to run the docker daemon and docker containers in user namespaces.

This requires the docker-rootless-extras package (available in community ) and enabling the cgroups service:

Additionally, the /etc/subuid and /etc/subgid files need to be set up as explained in the official documentation.

Docker Compose

‘docker-compose’ is in the ‘Community’ repository starting with Alpine Linux 3.10.

Isolate containers with a user namespace

adduser -SDHs /sbin/nologin dockremap addgroup -S dockremap echo dockremap:$(cat /etc/passwd|grep dockremap|cut -d: -f3):65536 >> /etc/subuid echo dockremap:$(cat /etc/passwd|grep dockremap|cut -d: -f4):65536 >> /etc/subgid

add to /etc/docker/daemon.json

You may also consider these options : ‘

"experimental": false, "live-restore": true, "ipv6": false, "icc": false, "no-new-privileges": false

You’ll find all possible configurations here[1].

Example: How to install docker from Arch

«WARNING: No limit support»

You might encounter this message when executing docker info . To correct this situation, we have to enable the cgroup_enable=memory swapaccount=1

Alpine 3.8

It may not have been the case before, but with Alpine 3.8, you must config cgroups properly

Warning: This seems not to work with Alpine 3.9 and Docker 18.06. Follow the instructions for grub or extlinux below instead.

echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab

Grub

If you use Grub, add the cgroup condition into /etc/default/grub , then upgrade your grub

GRUB_CMDLINE_LINUX_DEFAULT=". cgroup_enable=memory swapaccount=1"

Extlinux

With Extlinux, you add the cgroup condition, but inside of /etc/update-extlinux.conf

default_kernel_opts=". cgroup_enable=memory swapaccount=1"

then update the config and reboot

How to use docker

The best documentation on using Docker and creating containers is at the official docker site. Adding anything to it here would be redundant.

If you create an account at docker.com, you can browse through user images and learn from the syntax in contributed dockerfiles.

Official Docker image files are denoted on the website by a blue ribbon.

See also

Источник

Оцените статью
Adblock
detector