0

I pulled my own docker image from docker hub. It contains apache2 and some files. I wrote steps to run apache2 in forground and exposed port no 80. But while running the image, i am not able to see my apache2 home page.

I used the following manifest..

include 'docker'
docker::image { 'myimage':
}
docker::run { 'accessfiles':
image => 'myimage',
ports => ['80','80'],
expose => ['80','80'],
}
fuad
  • 25
  • 6

1 Answers1

0

But while running the image, i am not able to see my apache2 home page.

It depends on the url you are trying to access, and your host (Windows, Mac, Linux)

On Windows or Mac, you would need to port forward the port 80 in order to access http://localhost.
See "How do I configure docker compose to expose ports correctly?" as an example.

Or you would need to get the IP of the VM which runs docker (docker-machine IP <yourmachine>): in order to see http://<ip>

The OP fuad mentions in the comments it needed to specify the proper syntax for port mapping:

ports => ['80:80']
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Still not working... I think the problem is with puppet manifest.. If i run 'docker run -p 80:80 myimage' , then it works by entering my ip address in web browser.. @VonC – fuad Jul 02 '16 at 09:25
  • Thanks for your comments... Got it.. I mentioned ports => ['80:80'] and it works.. – fuad Jul 02 '16 at 10:20
  • @fuad Great. I have included your comment in the answer for more visibility. – VonC Jul 02 '16 at 10:21