docker 常用命令收集
自己工作中的docker常用命令记录
🕐
列出所有 images
# 列出所有 images
docker images删除 images
# 删除某个 image
docker rmi image_id
# 强制删除某个 image(有时候,会出现 container 在使用这个 image 的情况)
docker rmi image_id -fbuild 一个 image
# 指定位置,指定名称(name:tag)
docker build -t my-build-image:v1 -f ./docker/office-support-backend/Dockerfile .
# no cache
docker build --no-cache -t u12_core -f u12_core .docker里的 contab 默认不启动
# 启动
crond
# 检查是否真实启动<有进程id表示启动成功>
pgrep cron时区统一
- Alpine 方案
ENV TZ Asia/Shanghai
RUN apk add tzdata && cp /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo ${TZ} > /etc/timezone \
&& apk del tzdata网络不通
Host is unreachable - connect(2)
Failed to open TCP connection to xxx.xxx.xx.xx:1234 (Host is unreachable - connect(2)
# 添加信任<只是解除了ip的限制>
firewall-cmd --permanent --zone=trusted --add-source=172.18.0.2/16
# 端口 http/port
firewall-cmd --zone=public --add-port=3081/tcp --permanent
firewall-cmd --zone=public --add-service=http --permanent
# 重启
firewall-cmd --reload
firewall-cmd --complete-reload
# 查看列表
firewall-cmd --get-active-zones参考
- https://stackoverflow.com/questions/35594987/how-to-force-docker-for-a-clean-build-of-an-image
- https://linuxhint.com/crontab-not-running-troubleshooting/
- https://www.baeldung.com/ops/docker-cron-job
- https://forums.docker.com/t/cron-does-not-run-in-a-php-docker-container/103897
- https://cloud.tencent.com/developer/article/1626811
- https://ncona.com/2017/09/getting-rails-to-run-in-an-alpine-container/
- https://www.helmerdavila.com/blog/rails-6-running-docker-phpmyadmin