https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Xlice&feedformat=atomAlpine Linux - User contributions [en]2024-03-28T13:47:27ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=Docker&diff=18066Docker2020-09-12T10:59:23Z<p>Xlice: </p>
<hr />
<div>== Installation ==<br />
<br />
The Docker package is in the 'Community' repository. See [[Alpine_Linux_package_management]] how to add a repository.<br />
<br />
apk add docker<br />
<br />
Connecting to the Docker daemon through its socket requires you to add yourself to the `docker` group.<br />
<br />
addgroup username docker<br />
<br />
To start the Docker daemon at boot, see [[Alpine_Linux_Init_System]].<br />
<br />
rc-update add docker boot<br />
service docker start<br />
<br />
{{Note|On older version of Alpine Linux with older version of docker you'll also need to disable some kernel security flags in order to build images:}}<br />
<br />
<code>sysctl -w kernel.grsecurity.chroot_deny_chmod=0</code><br />
<br />
<code>sysctl -w kernel.grsecurity.chroot_deny_mknod=0</code><br />
<br />
For more information, have a look at the [https://github.com/docker/docker/issues/20303 corresponding Github issue].<br />
<br />
Anyway, this weakening of security is not necessary to do with Alpine 3.4.x and Docker 1.12 as of August 2016 anymore.<br />
<br />
=== Docker Compose ===<br />
<br />
'docker-compose' is in 'Community' repository since Alpine Linux >= 3.10.<br />
<br />
apk add docker-compose<br />
<br />
For older releases, do:<br />
<br />
'''To install docker-compose, first install pip:'''<br />
<br />
apk add py-pip python3-dev libffi-dev openssl-dev gcc libc-dev make<br />
pip3 install docker-compose</code><br />
<br />
== Isolate containers with a user namespace ==<br />
<pre><br />
adduser -SDHs /sbin/nologin dockremap<br />
addgroup -S dockremap<br />
echo dockremap:$(cat /etc/passwd|grep dockremap|cut -d: -f3):65536 >> /etc/subuid<br />
echo dockremap:$(cat /etc/passwd|grep dockremap|cut -d: -f4):65536 >> /etc/subgid<br />
</pre><br />
<br />
and add in '''/etc/docker/daemon.json'''<br />
<br />
<pre><br />
{ <br />
"userns-remap": "dockremap"<br />
}<br />
</pre><br />
<br />
''You may also consider these options : '''<br />
"experimental": false,<br />
"live-restore": true,<br />
"ipv6": false,<br />
"icc": false,<br />
"no-new-privileges": false'''''<br />
<br />
You will find all possible configurations here[https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file].<br />
<br />
== Example: How to install docker from Arch ==<br />
<br />
https://wiki.archlinux.org/index.php/Docker<br />
<br />
== "WARNING: No {swap,memory} limit support" ==<br />
<br />
You may, probably, encounter this message by executing <code>docker info</code>.<br />
To correct this situation we have to enable the <code>cgroup_enable=memory swapaccount=1</code><br />
<br />
==== Alpine 3.8 ====<br />
Well I'm not sure it wasn't the case before but for sure with Alpine 3.8 you must config cgroups properly<br />
<br />
'''''Warning''''': This seems ''not'' to work with Alpine 3.9 and Docker 18.06. Follow the instructions for grub or extlinux below instead.<br />
<br />
<pre>echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab</pre><br />
<pre><br />
cat >> /etc/cgconfig.conf <<EOF<br />
mount {<br />
cpuacct = /cgroup/cpuacct;<br />
memory = /cgroup/memory;<br />
devices = /cgroup/devices;<br />
freezer = /cgroup/freezer;<br />
net_cls = /cgroup/net_cls;<br />
blkio = /cgroup/blkio;<br />
cpuset = /cgroup/cpuset;<br />
cpu = /cgroup/cpu;<br />
}<br />
EOF<br />
</pre><br />
<br />
=== Grub ===<br />
Well; if you use Grub it is like any other linux and you just have to add the cgroup condition into <code>/etc/default/grub</code>, then upgrade your grub<br />
<br />
<pre>GRUB_CMDLINE_LINUX_DEFAULT="... e=memory swapaccount=1"</pre><br />
<br />
=== Extlinux ===<br />
With Extlinux you also add the cgroup condition but inside <code>/etc/update-extlinux.conf</code><br />
<br />
<pre>default_kernel_opts="... cgroup_enable=memory swapaccount=1"</pre><br />
<br />
than update the config and reboot<br />
<br />
<code>update-extlinux</code><br />
<br />
== '''How to use docker''' ==<br />
<br />
The best documentation for how to use Docker and create containers is at the main docker site. Adding anything more to it here would be redundant.<br />
<br />
'''http://docs.docker.com/'''<br />
<br />
if you create an account at docker.com you can browse through other user's images and learn from the syntax in contributor's dockerfiles.<br />
<br />
Official Docker image files are denoted by a blue ribon on the website.<br />
<br />
== See also ==<br />
* [https://www.erianna.com/creating-a-alpine-linux-repository/ Creating & Hosting an Alpine Linux Package Repository for Docker Packages]<br />
* [[Running Alpine in a Docker Container]]<br />
<br />
[[Category:Virtualization]]</div>Xlice