I have a dockerfile that works by itself, with
docker build -t image_apache .
docker run -tid -p 5000:80 --name=container_apache image_apache
This works, and I can connect to its webserver with 127.0.0.1:5000
But when I try to create a docker-compose.yml file to build and run the image with docker-compose, it doesn't appear to expose the port at all.
Here is the docker-compose.yaml
version: '3'
services:
  deploy_test:
    ports:
      - "8080:80"
    build: .
    working_dir: /tmp/artifacts
docker-compose build
docker-compose run deploy_test
My browser can't connect to 127.0.0.1:8080, and the apache log in the container doesn't show any attempts.
Do I just have a bad syntax for the port? It matches online samples.
please try using docker-compose run -p 8080:80 deploy_test as run command can not expose/publish ports by itself i.e. you need to specify it manually. For more information regarding same, please refer to its official documentation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With