How to connect to a docker container? I have the following Dockerfile:

FROM ubuntu:latest
MAINTAINER Valter Silva
RUN apt-get update
RUN apt-get install -y apache2
ADD index.html /var/www/html/
CMD /usr/sbin/apache2ctl -D FOREGROUND
EXPOSE 22
EXPOSE 80


This is how I build my image:

docker build --tags mob:latest .


Next, this is how I bring my container up:

docker run -d --name website mob


Then I check my container's ip via the following command:

docker network inspect bridge


I would like to execute a curl on this ip to ensure that my website is up and running:

curl 172.17.0.2


But for some reason, my command keeps hanging. I'm not sure why this is happening. I'm running my dockeron a MacOS system.
You can get to know if your site is up and running in the following way,

Map both the ports of inside container to the host using -p option and try to curl localhost:port

Scenario:-

Run your container with the following command,

docker run -d --name website -p 80:80 -p 22:22 mob


Explanation:-  -p host_port:container's_port

Now, curl localhost:80 or localhost:22

If your service is running properly, you will have got the response

P.S:- Make sure nothing is running in 80 and 20 on host before running the docker run command