Netatalk in a Docker container
An container serving Apple Filing Protocol file sharing, Tracker (search/spotlight integration), and mDNS server for service discovery.
I'm in the fast lane! Get me started
To quickly get started with running an Netatalk container first you can run the following command:
docker run --detach --publish 548:548 cptactionhank/netatalk:latest
Important: This does not announce the AFP service on the network; connecting to the server should be performed by Finder's
Go -> Connect Server (CMD+K) and then typing
Default configuration of Netatalk has two share called Share which shares the containers
/media/share and called TimeMachine which shares the containers
/media/timemachine mounting point. Host mounting a volume to this path will be the quickest way to start sharing files on your network.
docker run --detach --volume [host_path]:/media/share --volume [host_path]:/media/timemachine --publish 548:548 cptactionhank/netatalk:latest
The slower road
With the slower roads documentation some knowledge in administering Docker and Netatalk assumed.
There are two ways of configuring the Netatalk which is either by mounting a configuration file or editing the file from the container itself. Documentation of the configuration file
/etc/afp.conf can be found here.
Host mounted configuration
This is quite a simple way to change the configuration by supplying an additional docker flag when creating the container.
docker run --detach --volume [host_path]:/etc/afp.conf --volume [host_path]:/media/share --volume [host_path]:/media/timemachine --publish 548:548 cptactionhank/netatalk:latest
Container edited configuration
Other ways of enabling customizations of the Netatalk configuration file is by mounting the
--volume /etc such that this directory will remain persistent between restarts and then modify the configuration file. However the first option would be the recommended way to do this.
Setting up access credentials
To setup access credentials you should supply the following environment variables from the table below.
|AFP_USER||create a user in the container and allow it access to /media/share|
|AFP_UID||uid of the created user|
|AFP_GID||gid of the created user|
docker run --detach \ --volume /mnt/sda1/share:/media/share \ --net "host" \ --env AFP_USER=$(id -un) \ --env AFP_PASSWORD=secret \ --env AFP_UID=$(id -u) \ --env AFP_GID=$(id -g) \ cptactionhank/netatalk:latest
This replaces all occurrences of
[Global] log file = /var/log/netatalk.log [Share] path = /media/share valid users = %USER%
This image includes an avahi daemon which is off by default. Enable by setting the environment variable
docker run -e AVAHI=1 ...
Service discovery works only when the Avahi daemon is on the same network as your users which is why you need to supply
--net=host flag to Docker when creating the container, but do consider that
--net=host is considered a security threat. Alternatively you can install and setup an mDNS server on the host and have this describing the AFP service for your container.
Thanks to @rrva for his work updating this image to Netatalk version 3.1.8 and slimming down this image for everyone to enjoy.
This image has been created with the best intentions and an expert understanding of docker, but it should not be expected to be flawless. Should you be in the position to do so, I request that you help support this repository with best-practices and other additions.
If you see out of date documentation, lack of tests, etc., you can help out by either
- creating an issue and opening a discussion, or
- sending a pull request with modifications