0

I am beginner and just started using docker, before posting here I google a lot but a lot of mixed confusing result.

I started docker with this command

docker run -itd --name dockWeb2 -v /var/www/wordpress/ -p 80:80  atozchevara/rpi-apache-php5

hoping I would be able to directly mount wordpress installation onto container , as by default it picks internal path of container /var/www/index.php, to override it I used -v flag. but it doesn't work.

I tried using multiple ports by passing -p arguments again for each port but that too gives error docker run -itd --name dockWeb3 -v /var/www/wordpress/ -p 80:80 -p 22:22 atozchevara/rpi-apache-php5

66a959e4e99af8122705913005fcae12e2e8a5203da7b77ff1717751314fca28 docker: Error response from daemon: driver failed programming external connectivity on endpoint dockWeb3 (eb42a619a8c79961d35d59e0d8930a92541a20132525055afb3b0d2d87483e7f): Bind for 0.0.0.0:80 failed: port is already allocated.

otherwise Could have uploaded my wordpress using ssh to container's /var/www/ location.

1 Answer 1

1

For the first issue if you want to mount a volume from the host you need to use Bind mount a volume

docker run -itd --name dockWeb2 -v your_project_path:/var/www/wordpress/ 0.0.0.0:80 failed: port is already allocated.  atozchevara/rpi-apache-php5

For the post using -p 80:80 you are publishing container port 80 to the host port 80, and if the host port is already in use you got an error 0.0.0.0:80 failed: port is already allocated. try to use a different port -p 9090:80.

Sign up to request clarification or add additional context in comments.

5 Comments

hang on a sec, I referred /var/www/wordpress/ to the path on host machine on which docker is running, do you mean the path your_project_path is container internal path ?
lets say you have a wordpress directory on your machine exp "/home/amine/wordpress" and you want the wordpress dir to be mounted on your docker container in the path /var/www/wordpress , so simply you need to use -v "/home/amine/wordpress:/var/www/wordpress i hope this will clear things for you
for the second post, I am not using -p 80:80 twice, first I used -p 80:80 then i used -p 22:22 for ssh which means ports are different not the same so in that case how port is already allocated ?
you're already using the port 80 by another programme check your allocated ports or use a different port
Before using it I docker stop all my running containers

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.