Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rameezisrar's avatar

Add SSL certificate on the application deployed with Docker

I have ubuntu 18.04 server. The application is deployed with Docker and can be accessed with http. I need to add SSL certificate that I have received from a company. I cant use CertBot as it includes its own certificate. I need to make sure to include same certificate that I have received.

My Dockerfile

...
Copy certificate.pem /etc/ssl/certs

But I am still unable to make the site secure.

Any help will be much appreciated.

0 likes
7 replies
rameezisrar's avatar

Hey @sinnbeck thank you for the response.

Actually, I haven't installed Nginx on the ubuntu server.

On the ubuntu server, I have installed Docker only and Docker is running the php application using Apache image.

Sinnbeck's avatar

Ah fair enough. But I would assume that you can do the same with the php-apache image :) I havent used it myself, but should be possible :) Perhaps consider posting your docker-compose.yml and custom Dockerfile (I assume you are using both)

rameezisrar's avatar

@sinnbeck Here is the dockerfile

FROM php:5.6-apache
LABEL author="DEVOPS-IT"
 
# Copy application source
COPY . /var/www/html
COPY publiccert.pem /etc/ssl/certs/
RUN chown -R www-data:www-data /var/www

docker-compose file

version: '3.8'
services:
   app:
     image: company/portal
     deploy:
      mode: replicated
      replicas: 1
     ports:
      - "8085:443"
       - "8085:80"

Sinnbeck's avatar

Personally I would add my own custom apache config for the site. Go into the container and drab the default one. Modify it locally and have docker copy it in. :) /etc/apache2/sites-available/default.conf(if I recall correctly)

Please or to participate in this conversation.