0

I installed docker with the packages docker.io and lxc. I wanted to test docker while I create an apache2 webserver. I created the container with

sudo docker.io run -i -t -p :8080 ubuntu:14.10 /bin/bash

Than I installed apache2 with

apt-get install apache2

After I modified the ports.conf that the apache2 listen to port 8080 I started the apache2 service. After the call to the IP on port 8080 on the browser I don't get a result.

Do I have to note something else? Thanks

1 Answer 1

3

You've got a number of problems here so I think you may need to spend some more time learning Docker, see: Docker User Guide, but to give you a couple of pointers ...

  1. Firstly there's a problem with your -p option. You've only specified the port on the inside, i.e. in the docker container (8080). You haven't specified the port on the outside, i.e. the host. This means Docker will bind to some random port on the outside. You can find out what port that is by running docker ps. Then you'll see something like

    0.0.0.0:32769->8080/tcp 
    

    which indicates that if you visited port 32769 in your browser you might get through to Apache because Docker has bound port 32769 on the host to port 8080 inside the container.

    What you actually want to do is this: -p 8080:8080 to make sure that the port is the same on the host and in the container.

  2. Secondly it's not at all clear to me whether you've installed apache2 in the container or on the host. Normally you would write a Dockerfile based on the ubuntu image you want to use which specifies apache should be installed when the Docker image is built. This all happens before you run the container. You should avoid installing anything in a Docker container after you've run it, because it will be lost once you delete that instance of the container.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.