Reputation: 65
I've been trying to get this running for many MANY hours. I've been scouting docker docs, github repos and other stuff but I can't get it working for some reason.
My dockerfile:
FROM mattrayner/lamp:latest-1804
WORKDIR /app
RUN wget -O /tmp/lwt.zip http://downloads.sourceforge.net/project/lwt/lwt_v_1_6_3.zip && \
yes A | unzip /tmp/lwt.zip &&\
rm /tmp/lwt.zip &&\
mv connect_xampp.inc.php connect.inc.php
EXPOSE 80
CMD ["/run.sh"]
It build normally without any errors but when I run the image nothing appears in the /app
directory and I get just a basic Welcome to LAMP view on my browser.
Though,
If I do docker run -p "80:80" -it -v ${PWD}/app:/app mattrayner/lamp:latest-1804 /bin/bash
, cd /app
, copy and paste
wget -O /tmp/lwt.zip http://downloads.sourceforge.net/project/lwt/lwt_v_1_6_3.zip && \
yes A | unzip /tmp/lwt.zip &&\
rm /tmp/lwt.zip &&\
mv connect_xampp.inc.php connect.inc.php
it still doesn't work BUT if I exit and run the same docker run
command it works.
Docker LAMP instructions also state to do exactly as I have done:
FROM mattrayner/lamp:latest-1804
# Your custom commands
CMD ["/run.sh"]
As I followed these instructions I thought that everything would work nicely.
What's the catch here? It has something to do with the intermediate containers probably but I can't comprehend it (I'm not a devops or developer by trade, just a hobbyist).
Upvotes: 0
Views: 337
Reputation: 1
services:
webserver:
container_name: my-docker-website
build:
context: .
dockerfile: dockerfile
volumes:
- ./www:/var/www/html
ports:
- 8000:80
depends_on:
- mysql-db
mysql-db:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: sqlinjection
MYSQL_USER: db_user
MYSQL_PASSWORD: password
ports:
- "3366:3306"
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- mysql-db
ports:
- "8081:80"
environment:
PMA_HOST: mysql-db
MYSQL_ROOT_PASSWORD: password
Upvotes: -2
Reputation: 3691
That happens because you're doing this:
/app
dir in your docker image./app
dir when you mount volume, with content of your $PWD/app.If you are installing something doing docker build
in some dirs, don't mount into the same path.
If you need something in the same path, you can mount some concrete files, but not the whole dir, or it will override what you had in your docker image when container is created.
You can do wget somewhere else or download it into your ${PWD}/app and then mount it.
Upvotes: 4