Access web application that is running on apache from a Docker container inside a linux server that I access for ssh

Asked

Viewed 656 times

1

By my windows machine I have access to a linux server that is on the same network through an SSH. Do I need to access a web application that runs inside apache from a Docker container on that server, any idea how to do that? Currently I can only access it through the browser of the linux server and I want to access it through my windows machine.

2 answers

2


First of all you need to know if the network that this server is, can be accessed by your machine direct by IP, and can test this by pinging its ip.

If your machine can ping the server, it means it’s possible. This way, you need to upload this container by mapping a port you want, for example -p 8000:8000.

With the active container and the port mapped, you can access directly through the browser by typing the machine IP next to the port, example, 172.16.108.10:8000

1

After accessing the linux server by ssh, lists the containers that are running on the server running the command: "Docker ps"

checks the ID of the container you want to access and runs: Docker exec -it <id_do_container> /bin/bash

  • The problem I want to access the web page that runs on the container’s apache, not the container itself. Understand ?

  • 1

    You need to move the container up by mapping the port to some server port, e.g.: Docker run --name <nome> -p 80:80 Image:

  • The container will answer on the same port of the linux server, just access through the windows browser, put the ip_do_servor_linux:port ... ai it will direct to the container

  • I’ll try it here. Do you have any idea how I can link a container with an apache image to a container with a php image? I’ve got the two containers running but I think I need to connect the two somehow

  • 1

    Here’s a nice tutorial on how to do: https://www.cloudreach.com/blog/containerize-this-php-apache-mysql-within-docker-containers/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.