evertramos / docker-portainer-letsencrypt

Portainer docker container over SSL Certificate using Let's Encrypt automated by our webproxy docker-compose-letsencrypt-nginx-proxy
GNU Lesser General Public License v3.0
189 stars 52 forks source link

Create docker container with exposed port using portainer #1

Closed raqbit closed 6 years ago

raqbit commented 6 years ago

I am looking at using this to manage my docker containers, but I've found that it's not possible to add exposed ports without creating your own image (and thus exposing ports via the docker file) in portainer.

Can you confirm that the only way to use portainer with the nginx-gen setup is to modify dockerfiles? (Or use images which already expose their ports)

evertramos commented 6 years ago

If you do not want to use SSL you can just set:

version: '3'

services:
  portainer:
    container_name: ${CONTAINER_NAME}
    restart: unless-stopped
    image: portainer/portainer
    volumes:
      - ${PORTAINER_DATA_PATH}:/data
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "9000:9000"

networks:
    default:
       external:
         name: ${NETWORK}

If you plan to use SSL you must just generate your certificate with the url you intend to use and set the port option as above using the new version of our docker-compose.yml and ´.env´ file, excluding the hosts part of it, as of below:

version: '3'

services:
  portainer:
    container_name: ${CONTAINER_NAME}
    restart: unless-stopped
    image: portainer/portainer
    volumes:
      - ${PORTAINER_DATA_PATH}:/data
      - ${PORTAINER_SSL_PATH}:/certs
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "9000:9000"
    environment:
#      VIRTUAL_HOST: ${DOMAINS}
      LETSENCRYPT_HOST: ${DOMAINS}
      LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}

# ssl
      SSL:
      SSLCERT: ${PORTAINER_SSL_CERTIFICATE}
      SSLKEY: ${PORTAINER_SSL_KEY}

# Test of TLS certificate
#      TLSVERIFY:
#      TLSCACERT: ${PORTAINER_SSL_CA_CERTIFICATE}
#      TLSCERT: ${PORTAINER_SSL_CERTIFICATE}
#      TLSKEY: ${PORTAINER_SSL_KEY}

    command: --admin-password ${ENCRYPTED_PASSWORD}

networks:
    default:
       external:
         name: ${NETWORK}

This should work, I haven´t tested yet.. but will do so when get the time and reply.

Please confirm if you get it to work.

evertramos commented 6 years ago

Since we got no reply on that we will close it.