Skip to content

Docker stack with Wordpress & FTP

Andrew Stilliard edited this page Dec 25, 2018 · 3 revisions

Docker stack with Wordpress & FTP

The following docker-compose.yml file will deploy a wordpress image and an FTP server. The FTP server listen on the port 21 on the host, and will use ports 30000 to 30009 as passive ports.

It is important to make sure that, with this configuration, both containers are on the same host, to mount the same directory in both containers

Due to some limitations in docker-compose v3.2, you have to explicitly bind each used FTP ports to the host using the long syntax.

In the Wordpress container, the owner of the files has the UID 33 & GID 33, thus we set the UID & GID of the FTP user accordingly.

We end up with a docker compose file like bellow:

version: "3.2"
services:
  web:
    image: wordpress:4.8-apache
    # other configs for wordpress
    volumes:
      - ./data/wordpress:/var/www/html
  ftp:
    # optionally replace username/repo:tag with your name and image details
    image: stilliard/pure-ftpd:latest
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
    environment:
      PUBLICHOST: xxx.xxx.xxx.xxx
      FTP_USER_NAME: "bob"
      FTP_USER_PASS: "foobarqux"
      FTP_USER_HOME: "/var/www/html"
      FTP_USER_UID: 33
      FTP_USER_GID: 33
    volumes:
      - ./data/wordpress:/var/www/html
      - ./data/ftp:/etc/ssl/private
    ports:
      - target: 21
        published: 21
        protocol: tcp
        mode: host

# Bind each passive ports to the host
      - target: 30000
        published: 30000
        protocol: tcp
        mode: host
# ...