因此,我有以下docker-compose文件:
version: "3"
services:
webserver:
build:
context: ./bin/webserver
container_name: 'png-webserver'
restart: 'always'
ports:
- "18011:80"
- "14431:443"
links:
- mysql
volumes:
- ${DOCUMENT_ROOT-./www}:/var/www/html
- ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini
- ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled
- ${LOG_DIR-./logs/apache2}:/var/log/apache2
mysql:
build: ./bin/mysql
container_name: 'png-mysql'
restart: 'always'
ports:
- "13306:3306"
volumes:
- ${MYSQL_DATA_DIR-./data/mysql}:/var/lib/mysql
- ${MYSQL_LOG_DIR-./logs/mysql}:/var/log/mysql
- ./mysqlhome:/home
environment:
MYSQL_ROOT_PASSWORD: tiger
MYSQL_DATABASE: nubuilder
MYSQL_USER: deckoff
MYSQL_PASSWORD: deeppurple
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: 'png-phpmyadmin'
links:
- mysql
environment:
PMA_HOST: mysql
PMA_PORT: 3306
ports:
- '18080:80'
volumes:
- /sessions
以及以下Dockerfile(用于mariadb容器):
FROM mariadb:10.1
RUN mysql --defaults-extra-file='/home/secret' nubuilder4 < /home/nubuilder4.sql
RUN apt-get update && apt-get install -y nano
RUN bash -c 'echo [mysqld] >> /etc/mysql/my.cnf'
RUN bash -c 'echo sql-mode=NO_ENGINE_SUBSTITUTION >> /etc/mysql/my.cnf'
简而言之-似乎Dockerfile中的RUN命令永远不会运行。我希望将2行附加到文件中,并安装nano,但是这些都不会发生。启动容器后,我尝试运行它们,它们工作正常。好像我做错了。
而且,我不知道如何调试它。
答案 0 :(得分:0)
用于将nano和echo线安装到文件中的RUN命令似乎正确。
问题很可能出在RUN mysql --defaults-extra-file='/home/secret' nubuilder4 < /home/nubuilder4.sql
由于您正在安装卷/ home,因此我们无法对其进行调试。您确定此RUN mysql ...命令成功通过吗?
要调试:请更改docker-compose.yml而不是build:./bin/mysql,使用image:mariadb:10.1,然后连接到容器并使用mysql运行第一个命令。