Skip to content

Am I missing something. What's the difference between these two docker calls..and why does one work but the other doesn't? #713

Description

@GavinNL

Hello,

I'm trying to set up lets encrypt on my server, but I'm running into a weird issue. I'm running the two docker containers, and they seem work correctly

I have the following shell script called www.sh, which basically just starts up a nginx container and mounts the $PWD/docker_data folder to the html path. This seems to work correctly, and i can go to https://jelly.mydomain.com and I dont get any issues

#!/bin/bash
docker run  \
    --name www-proxy \
    --env "VIRTUAL_HOST=jelly.mydomain.com" \
    --env "LETSENCRYPT_HOST=jelly.mydomain.com" \
    --env "LETSENCRYPT_EMAIL=info@mydomain.com" \
    -v $PWD/docker_data:/usr/share/nginx/html:ro \
    nginx

But, I tried to set up the exact same call, but using a docker-compose file below. Now when i go to https://jelly.mydomain.com i keep getting a BAD GATEWAY ERROR.

docker-compose.yml

version: '3.3'
services:
    nginx:
        volumes:
            - "$PWD/docker_data:/usr/share/nginx/html:ro"
        environment:
            - VIRTUAL_HOST=jelly.mydomain.com
            - LETSENCRYPT_HOST=jelly.mydomain.com
            - LETSENCRYPT_EMAIL=info@mydomain.com
        container_name: www-proxy
        image: nginx

If I then shutdown the docker-compose run and run the shell script again, everything seem to work. Am I missing something here? Why does calling the docker run... command seem to work but the docker-compose not? If I docker exec .... /bin/bash into the containers, and call a curl localhost, both are serving the correct page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/questionIssue that might be transferred to Discussions

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions