For simple Factorio Server using Docker.
The first step will be to setup a docker swarm. Afterward, some kind of file share should be created, in this case, a Samba server was created on a separate NAS computer. This is important since it will contain all the server data, since if a node goes down, that is running Factorio, it will not have game data any.
The way in this node swarm is setup is that it uses only a single server instance running at any point, and uses high availability as its redundancy if any of the nodes where to die or for whatever reason stop working.
version: "3.10" services: factorio: image: factoriotools/factorio:1.1.104 volumes: - factorio_data:/factorio ports: - 34197:34197/udp - 27015:27015/tcp deploy: mode: replicated replicas: 1 resources: limits: memory: 1.0G placement: max_replicas_per_node: 1 restart_policy: condition: on-failure volumes: factorio_data: driver: local driver_opts: type: cifs o: username=yyyyyy,password=xxxxxx,uid=1000,gid=1000,noperm,vers=3.0,rw device: //serverhost/ServicesData/factorio
Start Docker Stack
Once all the files and dependencies are created. It is as simple as invoking the following. It will create a docker service from the compose file.
docker stack deploy -c factorio-compose.yml factorio
Secret for Samba – Optional
This step is optional, but it allows for storing the Samba credentials as a file that is not accessible in the docker-compose file.
printf "username=user password=1234 | docker secret create SambaMount -
docker secret create SambaMount smbcredentials.txt
Docker configuration, using Samba Share, using the cifs client.
version: "3.9" services: factorio: image: factoriotools/factorio:1.1.104 volumes: - factorio_data:/factorio ports: - 34197:34197/udp - 27015:27015/tcp deploy: mode: replicated replicas: 1 resources: limits: memory: 1.5G placement: max_replicas_per_node: 1 restart_policy: condition: on-failure secrets: - source: SambaMount target: /.smbcredentials uid: '1000' gid: '1000' mode: 0666 volumes: factorio_data: driver: local driver_opts: type: cifs o: credentials=/.smbcredentials,uid=1000,gid=1000,vers=3.0,noperm,rw device: //IP/Share/factorio secrets: SambaMount: external: true
Free/Open software developer, Linux user, Graphic C/C++ software developer, network & hardware enthusiast.