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,

    image: owncloud/server:${OWNCLOUD_VERSION}
    restart: always
      - ${HTTP_PORT}:8080
      - db
      - redis
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=owncloud
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
      - files:/mnt/data

I have set the variables as follows:

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,>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

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).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.