我想在docker的帮助下安装opensourcepos。当我运行docker-compose up命令时,显示以下错误。
第3/4步:添加database.sql /docker-entrypoint-initdb.d/database.sql
错误:服务'sqlscript'无法生成:添加失败:stat /mnt/sda1/var/lib/docker/tmp/docker-builder784255971/database.sql:无此类文件或目录
docker-compose.yml文件
version: '2'
volumes:
uploads:
driver: local
logs:
driver: local
networks:
app_net:
db_net:
services:
sqlscript:
build:
context: database/
dockerfile: Dockerfile
ospos:
build:
context: .
dockerfile: Dockerfile
container_name: ospos
restart: always
depends_on:
- mysql
expose:
- "80"
networks:
- app_net
- db_net
volumes:
- uploads:/app/public/uploads
- logs:/app/application/logs
environment:
- FORCE_HTTPS=true
- PHP_TIMEZONE=UTC
- MYSQL_USERNAME=root
- MYSQL_PASSWORD=
- MYSQL_DB_NAME=ospos
- MYSQL_HOST_NAME=mysql
mysql:
image: mariadb:10.3
container_name: mysql
restart: always
expose:
- "3306"
networks:
- db_net
volumes_from:
- sqlscript
environment:
- MYSQL_ROOT_PASSWORD= password
- MYSQL_DATABASE=ospos
- MYSQL_USER=root
- MYSQL_PASSWORD=
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
restart: always
depends_on:
- mysql
expose:
- "80"
networks:
- app_net
- db_net
environment:
- MYSQL_USERNAME=root
- MYSQL_ROOT_PASSWORD= password
- PMA_HOST=mysql
nginx:
image: nginx:1.15-alpine
container_name: nginx
restart: always
depends_on:
- ospos
- phpmyadmin
- certbot
volumes:
- ./docker/data/nginx/nginx.tmpl:/etc/nginx/nginx.tmpl:ro
- ./docker/data/nginx/error_log.log:/etc/nginx/error_log.log
- ./docker/data/certbot/conf:/etc/letsencrypt:ro
- ./docker/data/certbot/www:/var/www/certbot:ro
ports:
- "80:80"
- "443:443"
- "8000:8000"
networks:
- app_net
environment:
- WEB_DOMAIN= localhost
- ESC=$$
command: "/bin/sh -c 'envsubst < /etc/nginx/nginx.tmpl > /etc/nginx/nginx.conf & while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
certbot:
image: certbot/certbot
container_name: certbot
restart: always
volumes:
- ./docker/data/certbot/conf:/etc/letsencrypt
- ./docker/data/certbot/www:/var/www/certbot
networks:
- app_net
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
Docker文件
FROM php:7.3-apache
MAINTAINER jekkos
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
libicu-dev \
libgd-dev \
openssl
RUN a2enmod rewrite
RUN docker-php-ext-install mysqli bcmath intl gd
RUN echo "date.timezone = \"\${PHP_TIMEZONE}\"" > /usr/local/etc/php/conf.d/timezone.ini
RUN echo -e “$(hostname -i)\t$(hostname) $(hostname).localhost” >> /etc/hosts
WORKDIR /app
COPY . /app
RUN ln -s /app/*[^public] /var/www && rm -rf /var/www/html && ln -nsf /app/public /var/www/html
RUN chmod 755 /app/public/uploads && chown -R www-data:www-data /app/public /app/application
RUN [ ! -f test/ospos.js ] || sed -i -e "s/\(localhost\)/web/g" test/ospos.js
两个文件都在同一目录中。
答案 0 :(得分:0)
尝试
ADD database.sql /docker-entrypoint-initdb.d/database.sql
并将database.sql
移至数据库文件夹