Docker: change a 8080 port to something different

Hi, I use docker-compose to run ownCloud as described here LifeHacker: How to Set Up Your Own Private Cloud Storage Service in Five Minutes with ownCloud

The documentation is a bit out of date, linked docker-compose.yml does not exist so I installed whatever found. It contains, among others,

services:
  owncloud:
    image: owncloud/server:${OWNCLOUD_VERSION}
    restart: always
    ports:
      - ${HTTP_PORT}:8080
    depends_on:
      - db
      - redis
    environment:
      - OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=owncloud
      - OWNCLOUD_DB_HOST=db
      - OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
      - OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - OWNCLOUD_MYSQL_UTF8MB4=true
      - OWNCLOUD_REDIS_ENABLED=true
      - OWNCLOUD_REDIS_HOST=redis
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - files:/mnt/data

I have set the variables as follows:

export OWNCLOUD_VERSION=10.10
export OWNCLOUD_DOMAIN=localhost:9090
export ADMIN_USERNAME=admin
export ADMIN_PASSWORD=admin
export HTTP_PORT=9090

Now, I would like to get rid of that 8080 in ${HTTP_PORT}:8080 within docker-compose.yml by replacing it with something not occupied in my system. I changed to ${HTTP_PORT}:9091 but I am not sure if it helped:

# docker-compose ps
       Name                      Command                  State                             Ports                       
------------------------------------------------------------------------------------------------------------------------
owncloud_db_1         /sbin/tini -- /usr/bin/ent ...   Up (healthy)   3306/tcp                                          
owncloud_owncloud_1   /usr/bin/entrypoint /usr/b ...   Up (healthy)   8080/tcp, 0.0.0.0:9090->9091/tcp,:::9090->9091/tcp
owncloud_redis_1      /sbin/tini -- /usr/bin/ent ...   Up (healthy)   6379/tcp

The Apache configuration files are nowhere to be found on my system (Ubuntu 20). Maybe the www server runs within Docker. Any help in replacing that 8080?

I’d recommend you to read about docker, specially about port mapping.

The 8080 port set in the .yml file mustn’t be changed. It’s where ownCloud will be listening inside the container.
The HTTP_PORT variable is the external port of the container, which will be mapped to the 8080 port in the container. That can be configured to the port you want (in your cause 9090, but can be changed)

What you’re doing is that the port 9090 in your host will be redirected to the 9091 in the container, but there is nothing listening in the 9091 port of the container. That’s why you cannot connect to ownCloud from the outside.

What I assume you want is that the port 80 of your host is mapped to the 8080 of the container (which is where ownCloud is running). This way you could access to ownCloud via http://my.host

Note that for HTTPS access, you’re expected to use a proxy or something similar to handle the HTTPS connection (nginx seems popular for this, I think). Basically, the flow would be client --(https)--> nginx --(http)--> ownCloud
Only nginx exposes the https port, and the connection between nginx and ownCloud happens inside the docker network (which isn’t exposed)

The Apache configuration files are nowhere to be found on my system (Ubuntu 20). Maybe the www server runs within Docker. Any help in replacing that 8080 ?

Yes, the apache server is inside the ownCloud’s container, and no, you aren’t expected to touch those files.

1 Like

Thanks, now I can access the admin interface and I have even sent a test e-mail.

Unfortunately, it complains about no working Internet connection (details here Docker "No internet connection" even if remote admin, SMTP works - #2 by d01010101).