- Docker
- Docker rootless
- Docker Compose
- Isolate containers with a user namespace
- Example: How to install docker from Arch
- «WARNING: No limit support»
- Alpine 3.8
- Grub
- Extlinux
- How to use docker
- See also
- How to create Alpine Container in Docker
- Steps to install Alpine on the Docker container
- 1. Pull Docker Alpine Image
- 2. Check the available images
- 3. Create Alpine Linux Container
- 4. Connect to Alpine container command line
- 5. Set root password
- Leave a Comment Cancel reply
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
How to create Alpine Container in Docker
Alpine Linux is popular because of its small size and fast speed. On Docker, its image is of few Mbs, hence consuming less space and resources. Users can opt for it to install a web server, database server such as MySQL, and more… It uses its own package manager called apk to install the packages available through its repository. Being lightweight is the reason why many platforms used it to set up container services.
Here in this article, we will see the steps to install Alpine Image on Docker to create a container. However, those who are interested in running the docker service on Alpine Linux can see our article: How to install Docker Engine on Alpine Linux.
Steps to install Alpine on the Docker container
To follow this tutorial, we are assuming you already have Docker service installed on your existing system and now you want to use the same to create a container with Alpine Image.
1. Pull Docker Alpine Image
By default, the minimal Docker image based on Alpine Linux is available in the Docker Hub repository. Hence, we just need to pull and install it to create a container. Here is the command to follow:
2. Check the available images
Let’s check whether the downloaded image is available to create a container or not. For that just run the given command:
3. Create Alpine Linux Container
In the result, you will see the Alpine image you have just pulled from the Docker library. Now, we can create as many containers running with Alpine Linux. Here is the command to create one.
docker run -it --name myalpine -d alpine
In the above command:
—name myalpine is the name of the container we want to create.
alpine is the name of the image we have downloaded
-d is the option to run the container in the background.
To check what are the containers already running on your system, we can use:
4. Connect to Alpine container command line
Now, we have the Alpine Linux container running in the background, let’s connect to its command for issuing commands.
sudo docker exec -it --user root myalpine /bin/sh
Although we have mentioned the particular user in the above command, however, even if you haven’t, by default it will connect using the root user only.
To exit the command line of Alpine, type:
5. Set root password
If you want to set a root password for the Alpine Linux container then after switching to its command line using the previous step, just type:
Enter the new password two times and you are done.
Other Articles:
Leave a Comment Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.