Docker Cron 未启动:"unknown flag: --rm"
Docker Cron does not start: "unknown flag: --rm"
有经验的问题:
命令 * * * * * $(command -v docker) docker run --rm -it --env-file=/home/ubuntu/.env ghcr.io/sebastix/crypto-dca:latest buy 10 ADA
不会启动。这在文件中进行了测试
- crontab -e
- sudo crontab -e
- 须藤纳米 /etc/crontab
日志电子邮件总是打印:
unknown flag: --rm
See 'docker --help'.
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/root/.docker")
...
如果我手动 运行 命令(不使用 cron),它的效果非常好 (docker run --rm -it --env-file=/home/ubuntu/.env ghcr.io/sebastix/crypto-dca:latest buy 10 ADA
)。同样适用于 docker run --rm -it --env-file=/home/ubuntu/.env ghcr.io/sebastix/crypto-dca:latest balance
我的系统:
我 运行正在使用 Raspberry Pi 4 ubuntu OS 20.04.3 LTS 64 位。
Docker 本身是本地安装的 (sudo apt install docker.io
)
Docker compose 是使用 Python3-pip 设置的(你知道,aarch64 架构问题 docker...)
docker version
的输出:
Client:
Version: 20.10.7
API version: 1.41
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu1~20.04.2
Built: Fri Oct 1 14:05:40 2021
OS/Arch: linux/arm64
Context: default
Experimental: true
Server:
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu1~20.04.2
Built: Fri Oct 1 03:27:17 2021
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.5.2-0ubuntu1~20.04.3
GitCommit:
runc:
Version: 1.0.0~rc95-0ubuntu1~20.04.2
GitCommit:
docker-init:
Version: 0.19.0
GitCommit:
docker info
的输出:
Client:
Context: default
Debug Mode: false
Server:
Containers: 3
Running: 2
Paused: 0
Stopped: 1
Images: 3
Server Version: 20.10.7
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version:
runc version:
init version:
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.4.0-1044-raspi
Operating System: Ubuntu 20.04.3 LTS
OSType: linux
Architecture: aarch64
CPUs: 4
Total Memory: 1.805GiB
Name: ubuntu
ID: JFJA:TP4G:DR7E:2ZRU:A4SL:KOQY:V2CG:5RQP:B2E4:VT4T:ZYWS:TFHO
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory TCP limit support
WARNING: No oom kill disable support
docker image inspect [imageID]
的输出:
[
{
"Id": "sha256:31f6111bddfcb06247fd5f8281b11f992826b088e557829c1673b2a440384bc8",
"RepoTags": [
"ghcr.io/sebastix/crypto-dca:latest"
],
"RepoDigests": [
"ghcr.io/sebastix/crypto-dca@sha256:0af2b744cba7a8a8749ea01cadcdc468dee5f144a0adbc9e2bc6afa36409e7ff"
],
"Parent": "",
"Comment": "buildkit.dockerfile.v0",
"Created": "2021-08-17T19:38:45.819153753Z",
"Container": "",
"ContainerConfig": {
"Hostname": "",
"Domainname": "",
"User": "",
...
sudo crontab -e
的输出:
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
#
# Bitcoin-dca by Sebastix
MAILTO="my@mail.com"
* * * * * $(command -v docker) docker run --rm -it --env-file=/home/ubuntu/.env ghcr.io/sebastix/crypto-dca:latest buy 10 ADA
#
解决方案很简单:我必须同时删除 -it
和第二个 docker
语句。
工作指令:* * * * * $(command -v docker) run --rm --env-file=/home/ubuntu/.env ghcr.io/sebastix/crypto-dca:latest buy 10 ADA --yes
附加的-yes
将自动执行购买而不需要确认。
#感谢@MarkoE 帮助我解决了我的问题!
有经验的问题:
命令 * * * * * $(command -v docker) docker run --rm -it --env-file=/home/ubuntu/.env ghcr.io/sebastix/crypto-dca:latest buy 10 ADA
不会启动。这在文件中进行了测试
- crontab -e
- sudo crontab -e
- 须藤纳米 /etc/crontab
日志电子邮件总是打印:
unknown flag: --rm
See 'docker --help'.
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/root/.docker")
...
如果我手动 运行 命令(不使用 cron),它的效果非常好 (docker run --rm -it --env-file=/home/ubuntu/.env ghcr.io/sebastix/crypto-dca:latest buy 10 ADA
)。同样适用于 docker run --rm -it --env-file=/home/ubuntu/.env ghcr.io/sebastix/crypto-dca:latest balance
我的系统:
我 运行正在使用 Raspberry Pi 4 ubuntu OS 20.04.3 LTS 64 位。
Docker 本身是本地安装的 (sudo apt install docker.io
)
Docker compose 是使用 Python3-pip 设置的(你知道,aarch64 架构问题 docker...)
docker version
的输出:
Client:
Version: 20.10.7
API version: 1.41
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu1~20.04.2
Built: Fri Oct 1 14:05:40 2021
OS/Arch: linux/arm64
Context: default
Experimental: true
Server:
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu1~20.04.2
Built: Fri Oct 1 03:27:17 2021
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.5.2-0ubuntu1~20.04.3
GitCommit:
runc:
Version: 1.0.0~rc95-0ubuntu1~20.04.2
GitCommit:
docker-init:
Version: 0.19.0
GitCommit:
docker info
的输出:
Client:
Context: default
Debug Mode: false
Server:
Containers: 3
Running: 2
Paused: 0
Stopped: 1
Images: 3
Server Version: 20.10.7
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version:
runc version:
init version:
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.4.0-1044-raspi
Operating System: Ubuntu 20.04.3 LTS
OSType: linux
Architecture: aarch64
CPUs: 4
Total Memory: 1.805GiB
Name: ubuntu
ID: JFJA:TP4G:DR7E:2ZRU:A4SL:KOQY:V2CG:5RQP:B2E4:VT4T:ZYWS:TFHO
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory TCP limit support
WARNING: No oom kill disable support
docker image inspect [imageID]
的输出:
[
{
"Id": "sha256:31f6111bddfcb06247fd5f8281b11f992826b088e557829c1673b2a440384bc8",
"RepoTags": [
"ghcr.io/sebastix/crypto-dca:latest"
],
"RepoDigests": [
"ghcr.io/sebastix/crypto-dca@sha256:0af2b744cba7a8a8749ea01cadcdc468dee5f144a0adbc9e2bc6afa36409e7ff"
],
"Parent": "",
"Comment": "buildkit.dockerfile.v0",
"Created": "2021-08-17T19:38:45.819153753Z",
"Container": "",
"ContainerConfig": {
"Hostname": "",
"Domainname": "",
"User": "",
...
sudo crontab -e
的输出:
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
#
# Bitcoin-dca by Sebastix
MAILTO="my@mail.com"
* * * * * $(command -v docker) docker run --rm -it --env-file=/home/ubuntu/.env ghcr.io/sebastix/crypto-dca:latest buy 10 ADA
#
解决方案很简单:我必须同时删除 -it
和第二个 docker
语句。
工作指令:* * * * * $(command -v docker) run --rm --env-file=/home/ubuntu/.env ghcr.io/sebastix/crypto-dca:latest buy 10 ADA --yes
附加的-yes
将自动执行购买而不需要确认。
#感谢@MarkoE 帮助我解决了我的问题!