"The page isn’t redirecting properly" when runn

Well, I moved the binary you told me to download to ~/docker/bin/ and made a bind mount:

caddy:
    image: caddy
    container_name: caddy
    hostname: caddy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
    environment:
      - DOMAIN
      - CF_API_EMAIL_FILE=$USERDIR/docker/traefik/cloudflare-api-email
      - CF_API_KEY_FILE=$USERDIR/docker/traefik/cloudflare-api-key
    volumes:
      - $USERDIR/docker/shared/Caddyfile:/etc/caddy/Caddyfile:ro
      - $USERDIR/docker/caddy/data:/data
      - $USERDIR/docker/caddy/config:/config
      - type: bind
        source: $USERDIR/docker/caddy/bin/caddy
        target: /usr/bin/caddy

But it’s saying:

ERROR: for caddy  Cannot start service caddy: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"caddy\": executable file not found in $PATH": unknown

Sorry, wrong nomenclature. Just do this, I think:

- $USERDIR/docker/caddy/bin/caddy:/usr/bin/caddy

I don’t think it was the nomenclature. It’s still not finding the executable.

Gah. Well um… Build from a Dockerfile like this I guess:

FROM caddy:latest

COPY ./bin/caddy /usr/bin/caddy

RUN chmod +x /usr/bin/caddy

Hopefully that works… Sorry for the trouble.

FROM caddy:latest

And that will give me the master build?

Hopefully that works… Sorry for the trouble.

No worries :slightly_smiling_face:

That gives you the latest docker image, but then you COPY the binary from your host machine into the docker image to replace the one that was already there, at build time (I was trying to get you to mount it at runtime but that wasn’t working).

You’ll need to adjust the COPY path to wherever you put that Dockerfile, and update your compose file to do something like build: ./caddy (with the path being the dir where you have the Dockerfile) instead of image: caddy. Then when you docker-compose up -d it should build it by pulling in the binary you have on disk.

Can we just troubleshoot this without Docker? It’ll probably be much easier…

How do I do it without Docker? Install the package?

Just download it and run it.

Oh. So do I just do ./caddy start? How do I get it to recognize my Caddyfile I made before?

Hi,
I wonder what is the proxy config of your caddy instance.
I’m not familiar with docker (especially with caddy) but do you have any file like this ?

/etc/systemd/system/docker.service.d/https-proxy.conf

When I read your post, my first thought was a docker config problem : and search this specific error if it can help (i’m sure you did this already :slight_smile: ) : ssl - Docker not able to pull images behind proxy TLS handshake timeout - Stack Overflow

Thanks for your help, but that file doesn’t seem to exist unfortunately.

1 Like

@matt sorry to bother you, but what should I do next?

To run Caddy without Docker? Simply follow any of our documentation guides, for example: Getting Started — Caddy Documentation

If you have specific questions about the command line interface: Command Line — Caddy Documentation

Ok thanks. I’ll report back with my errors.

How do I get around the bind address already being in use?

run: loading initial config: loading new config: starting caddy administration endpoint: listen tcp 127.0.0.1:2019: bind: address already in use

I’ve stopped Caddy’s Docker container.

Just stop whatever process is using that port.

I usually use netstat to figure out which process that is, but here’s a link to a guide with a few methods you can use.

https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/

2 Likes

Thanks I managed to figure out it was a zombie process of caddy from earlier. How can I pass my environment variables from my Dockerized Caddy? It’s not able to get my certs because it doesn’t have my Cloudflare email and password.

I’m assuming you’re not asking how to pass env vars into Docker, but instead how to set env vars outside of Docker?

Depending on shell and/or distro, you can just set them on the command line before you run Caddy. bash lets you simply run name=value as its own command to set variables in the current session, although you’ll want to export them if you will be running Caddy in the background (i.e. caddy start) - man bash has more info (wayyyy more info, search for the ENVIRONMENT heading).

Have a look at man environ on the command line to learn more, and also man env for a tool you can use to set them inline for a specific process.