Docker Community Forums

Share and learn in the Docker community.

Docker compose - add container to dedicated network

Hi

I am stuck while trying to create a couple of docker containers and run them within a dedicated network. The idea is (as far as i undersootd) that within this network the containers can talk to each other over their normal ports (like mysql databse on 3306) and that this does not clash with containers or normal software operating on the same ports but not in the same docker-network".

The specific situation is that I have a Linux server and I run seafile (seafile.com - opensource cloud solution) on it.
I also run Mailcow via docker in it. mailcow is not in a specific network.

Now I would like to run another instance of seafile via docker. I would use nginx to make that seafile instance available. But I get stuck because when I start the docker-compose file, I get error messages that all the ports are already busy.

ERROR: for seafile-docs-mysql Cannot start service db: b’driver failed programming external connectivity on endpoint seafile-docs-mysql (a4a81e4fe4d747e15f6e4a05f7604513413225e50e594469e828bf1114367d3f): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use’

I think i need tp start the conatiners that are combined with the docker-compose in a dedicated network.

But I don’t understand how.

The offical (very very short) manual gives this (from https://docs.seafile.com/wikis/seafiledocs-admin-manual-en/deploy-community-edition.md) is:

version: '2.0'
services:
  db:
image: mariadb:10.3
container_name: seafile-docs-mysql
ports:
  - 3306:3306
environment:
  - MYSQL_ROOT_PASSWORD=db_dev  # Set the root's password of MySQL service.
  - MYSQL_LOG_CONSOLE=true
volumes:
  - /opt/mysql-data:/var/lib/mysql  # Specify the data directory of MySQL.

  memcached:
image: memcached:1.4-alpine
container_name: seafile-docs-memcached
ports:
  - 11211:11211
      
  seafile:
image: seafileltd/seafile-docs:latest
container_name: seafile-docs
ports:
  - 80:80
#     - 443:443  # If https is enabled, cancel the comment.
volumes:
  - /opt/seafile-data/:/shared/seafile   # Specifies the path to the seafile data persistent store.
environment:
  - DB_HOST=db
  - DB_ROOT_PASSWD=db_dev
  - SEAFILE_ADMIN_EMAIL=me@example.com # Specifies seafile admin user, default is me@example.com
  - SEAFILE_ADMIN_PASSWORD=asecret     # Specifies seafile admin password, default is asecret
  - SEAFILE_SERVER_LETSENCRYPT=false   # Whether to use https or not
  - SEAFILE_SERVER_HOSTNAME=docs.seafile.com # Specifies your host name if https is enabled
depends_on:
  - db
  - memcached

I now want to add something like the below to it. But I don’t understand what I should do,

networks:
  seafilenet:
    ipam:
    config:
      - subnet 172.20.0.0/24
      - gateway: 172.20.0.1

But it dows not work. And I don’t think that the containers run in that network.
I really hope that someone understands the issue I have and can point me into the right direction. I am happy to explain more, but I am unsure whaty else to write.

I guess it’s quite simple, but I am too newbie…

Thanks in advance for any help,

KR, Chris