Getting started with docker and https

Hi all,

I am using Nextcloud with success on an ubuntu server vm. But as my capacity runs out, I have bought a new server where I want only docker containers. So I wanted to migrate to docker with a fresh installation. I will export/import calendar and contacts later. But I am a little bit to supid to get https to run. I have zero experience with nginx, but apache. I was using a self signed certificate on my actual setup and it works just fine.
So this setup with docker compose is working, but of course without SSL. I wanted to enable SSL inside this container, but it failed. I don’t want to use Lets Encrpyt - just want to use another self-signed certificate and run this with Nextcloud. On the other side I have seen the standard docker container does not contain all “add-ons” or the “full” installation like ImageMagick. Can you guys share an example how I get a full-installation?

version: '2' 
image: mariadb
restart: unless-stopped
  - ./database:/var/lib/mysql
  - MYSQL_USER=nextcloud
  - MYSQL_DATABASE=nextcloud
  - nextcloudnet

image: dsteinkopf/backup-all-mysql:latest
restart: unless-stopped
  - 'MYSQL_CONNECTION_PARAMS=--user=root --host=db --password=pw'
  - db
  - ./db_backup/mysql-backup:/var/dbdumps
  - nextcloudnet
image: nextcloud:apache
restart: unless-stopped
  - 6005:80
  - db
  - ./nextcloud/var_www_html:/var/www/html
  - ./nextcloud/data:/var/www/html/data
  - ./nextcloud/etc_apache2:/etc/apache2
  - /etc/localtime:/etc/localtime:ro
  - /etc/timezone:/etc/timezone:ro
  - nextcloudnet
# empty

Any help would be AWESOME! :slight_smile:


If it is supposed to be a pure docker server, switch to Traefik:
It will make everything much easier. is also useful.

Edit: Why do you not want to use let’s encrypt?


thank you for your quick answer.
The server should only be available inside the local network. I suggest that I need permanent internet access with lets encrpyt to validate the certificate. On the other side, I do not have a domain, so I work with static ip adresses.
Maybe I am wrong…

I will have a look on treafic. I am running portainer - awesome container :wink:


If you want to extend the nextcloud docker image you have to write your own docker file. and then use this image in your docker compose file.


this (run as root or a user with full sudo rights)

curl -s | /bin/bash
ansible-pull --clean --force --checkout devel -d ~/nextcloud -i 'nextcloud' -U nextcloud.yml \
-e "next_archive=" \
-e "fqdn=$(hostname -f)" \
-e "ssl_certificate_type=selfsigned" \
-e "talk_install=false" \
-e "install_collabora=false" \
-e "dhparam_numbits=1024"

should setup your new nextcloud in 5-10 minutes. but it’s not docker based.

Thanks for sharing. But it should be dockerized in all circumstances.


Hi, is there no way to put this in the compose file, so it is created when the container is started?
Otherwise I need to create my own dockerfile whenever there is an update…

no. docker-compose reads the docker composefile and that includes the docker file to create a new image. every time there is a update of next cloud or of the used components (apache, php, etc. pp.). but you have to trigger this.
compose and docker file will remain always the same. only the docker image will be rebuild and started as a new container.

Thank you for your answer. I will have a look into that.

I have tried the lets encrypt solution. without an domain name it is not working. therefore I am still searching for a simple suolutiojn using a self signed certificate. Somewhere I will need to change a config I guess…

building your own image:

i’m not sure but instead of image: nextcloud:apache you have to use build: where_your_docker_file_is_dir .

about certificates

letsencrypt makes no sense without your own domain. letsencrypt will validate if you are the owner of that your server has to answer request from a letsencrypt validation server. otherwise you could get a certificate for :wink: (there are ‘offline’ methodes to validate that you are the owner of your domain. but still you need a domain.)

to get your certificate. the following is one example

you may also use the ssl generator

quick howto: you generate once the certificates and use the COPY command in the docker file of your nextcloud image to copy them into this image.
you include in your compose file a one time run of the generator and write the certificates into a docker volume shared with the nextcloud image.

and have to change the apache config in the nextcloud image (with a COPY statement) to use the certificates.

Thank you guys.
I was able to setup nginx-revers with a self-signed certificate with success. Whoohoo :wink:

I will have a look at these link tomorrow. Enough for today. Thank you guys!^^


Hello guys,

I have now build my own docker image based on nextcloud:apache.
Maybe I just needed some time to think about how it works - but I was able to enable SSL and use my “Full” image in docker-compose. I was wondering how much new packages was installed with the “full” isntallation, it needs about 5 min to build the image.

Thank you so much for your help. Very appreciated.