Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker compose not exposing ports

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.

like image 324
Kenny Ostrom Avatar asked Oct 23 '25 02:10

Kenny Ostrom


1 Answers

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.

like image 146
semicolon Avatar answered Oct 27 '25 02:10

semicolon