skip to Main Content

I have docker-compose and podman-compose installed on the linux server (RHEL8.6)
I have the docker-compose.yaml file in the directory, which is as shown :

version: '3'

services:
  serviceA:
    image: 'AA/XXX:XX.XX.XX'
    ports:
       - "8081:8081"          
    restart: 'always'
    working_dir: /var/serviceA
    environment:
      TZ: "Europe/Berlin"
    volumes:
      - /var/serviceA:/var/serviceA
      - ${JAVA_HOME}/lib/security/cacerts:/etc/ssl/certs/java/cacerts

I run the podman-compose up -d and see that the container is running. However I cannot access it via https://localhost:8081

So when I do a podman-compose up, I see that it shows the following log:

Listening on http://localhost:8080

Why is it that podman does not take the port I specify on the compose file? Anything I am missing here?

2

Answers


  1. That Listening on http://localhost:8080 messages comes from the application running inside the container. Podman takes care of mapping a host port to the container port.

    If you want to expose the containerized service on host port 8081, you would need to write:

    services:
      serviceA:
        ports:
          - 8081:8080
    

    The syntax of entries in the ports list is <host port>:<container port>.

    Login or Signup to reply.
  2. When using Podman, there is a difference in how ports are accessed compared to Docker. By default, Podman binds to the host’s IP address instead of localhost, which can cause the services to be inaccessible via https://localhost:8081. To access the services, you need to determine the IP address of your host machine and use that in the URL.

    Here’s what you can do:

    Find the IP address of your host machine: You can use the ip addr or ifconfig command in the terminal to find the IP address associated with your network interface. Look for an address in the range of 192.168.x.x or 10.x.x.x. For example, if your IP address is 192.168.1.100, use that in the URL instead of localhost.

    Update the URL: Instead of accessing the service using https://localhost:8081, access it using https://:8081. Replace with the actual IP address you found in the previous step.

    For example, if your host IP is 192.168.1.100, the URL would be https://192.168.1.100:8081.

    By using the IP address of your host machine instead of localhost, you should be able to access the services running inside the Podman containers.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search