version: "3"
services:
mysql:
image: mysql:latest # mysql:oracle
restart: always
container_name: mysql
command:
- --lower_case_table_names=1
ports:
- 3306:3306
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/setup.sql
environment:
- MYSQL_ROOT_PASSWORD=123456
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "mysql"]
timeout: 5s
retries: 20
my_server:
build: .
restart: always
depends_on:
mysql:
condition: service_healthy
ports:
- 9999:9999
links:
- mysql
environment:
- ADMIN_PASSWD=admin # 这个会覆盖Dockerfile里面的内容
Dockerfile内容如下:
FROM sanicframework/sanic:3.8-latest
WORKDIR /sanic/my_server
COPY . /sanic/my_server
COPY . .
RUN pip install -r requirements.txt
EXPOSE 9999
CMD ./start.sh
RUN apk update
RUN apk --update add gcc musl-dev libffi-dev openssl-dev
RUN apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo
RUN pip install -r requirements.txt
EXPOSE 9999
RUN apk del --purge gcc musl-dev libffi-dev openssl-dev
FROM sanicframework/sanic:3.8-latest
WORKDIR /sanic/my_server
COPY . /sanic/my_server
COPY . .
RUN apk update
RUN apk --update add gcc musl-dev libffi-dev openssl-dev
RUN apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo
RUN pip install -r requirements.txt
EXPOSE 9999
RUN apk del --purge gcc musl-dev libffi-dev openssl-dev
CMD ./start.sh $ADMIN_PASSWD
当你再次运行docker compose up时候,又出现问题,提示如下错误
/bin/sh: ./start.sh: not found
![在这里插入图片描述](https://img-blog.csdnimg.cn/6e29c466a8734e50ad81fd90b9190a2d.png
RUN dos2unix ./start.sh
FROM sanicframework/sanic:3.8-latest
WORKDIR /sanic/my_server
COPY . /sanic/my_server
COPY . .
RUN apk update
RUN apk --update add gcc musl-dev libffi-dev openssl-dev dos2unix
#
# The Rust available by default in Alpine < 3.12 is older than the minimum supported version.
# https://cryptography.io/en/latest/installation.html
#
RUN apk add gcc musl-dev python3-dev libffi-dev openssl-dev dos2unix
RUN pip install -r requirements.txt
EXPOSE 9999
RUN apk del --purge gcc musl-dev libffi-dev openssl-dev dos2unix
VOLUME ["/sanic/license/config", "/sanic/license/log"]
CMD ./start.sh $ADMIN_PASSWD