我RUN在Dockerfile中有一些命令,我想在-no-cache每次构建Docker镜像时运行它.
我理解docker build --no-cache将禁用整个Dockerfile的缓存.
是否可以为特定的RUN命令禁用缓存?
我有一个使用Gunicorn的Django Web应用程序并在本地运行良好,但是当我在EC2上部署应用程序时,我看到Gunicorn失败了:
$ gunicorn_django -b 127.0.0.1:8000 --settings=myapp.settings.dev --debug --log-level info
2012-09-16 17:39:24 [28333] [INFO] Starting gunicorn 0.14.6
2012-09-16 17:39:24 [28333] [INFO] Listening at: http://127.0.0.1:8000 (28333)
2012-09-16 17:39:24 [28333] [INFO] Using worker: sync
2012-09-16 17:39:24 [28336] [INFO] Booting worker with pid: 28336
2012-09-16 17:39:24 [28336] [INFO] Worker exiting (pid: 28336)
2012-09-16 17:39:24 [28333] [INFO] Shutting down: Master
2012-09-16 17:39:24 [28333] [INFO] Reason: Worker failed to boot.
Run Code Online (Sandbox Code Playgroud)
我尝试使用--spew但是它一直在运行并且没有显示错误.
我该如何调试此问题?
GNU Make有-B强制make忽略现有目标的选项.它允许重建目标,但它也会重建目标的所有依赖关系树.我想知道有没有办法强制重建目标而不重建其依赖项(使用GNU Make选项,Makefile中的设置,类似兼容make的软件等)?
问题的插图:
$ mkdir test; cd test
$ unexpand -t4 >Makefile <<EOF
huge:
@echo "rebuilding huge"; date >huge
small: huge
@echo "rebuilding small"; sh -c 'cat huge; date' >small
EOF
$ make small
rebuilding huge
rebuilding small
$ ls
huge Makefile small
$ make small
make: 'small' is up to date.
$ make -B small
rebuilding huge # how to get rid of this line?
rebuilding small
$ make --version | head …Run Code Online (Sandbox Code Playgroud) 我有一个postgres:9.5.6-alpine容器,另一个名为web的容器,必须链接到它.我想在启动后运行create_db.shpostgres容器中命名的脚本并执行docker-entrypoint.sh,以便创建数据库和用户并恢复备份.我docker-compose.yml(postgres部分):
postgres:
build: ./postgres
container_name: postgres
volumes:
- /shared_folder/postgresql:/var/lib/postgresql
ports:
- "5432:5432"
command: sh /home/create_db.sh
Run Code Online (Sandbox Code Playgroud)
内容create_db.sh是:
#!/bin/sh
psql -d template1 -U postgres
psql --command "CREATE USER user WITH PASSWORD 'userpassword';"
psql --command "CREATE DATABASE userdb;"
psql --command "GRANT ALL PRIVILEGES ON DATABASE userdb to user;"
psql --command "\q;"
psql -U user -d userdb -f /var/lib/postgresql/backup.sql
exit
Run Code Online (Sandbox Code Playgroud)
当我跑docker-compose build,然后docker-compose up我得到这个:
Attaching to postgres, web
postgres | psql: could not connect to …Run Code Online (Sandbox Code Playgroud)