gpt4 book ai didi

Docker Cron 不启动 : "unknown flag: --rm"

转载 作者:行者123 更新时间:2023-12-05 04:43:53 28 4
gpt4 key购买 nike

遇到的问题:

命令 * * * * * $(command -v docker) docker run --rm -it --env-file=/home/ubuntu/.env ghcr.io/sebastix/crypto-dca:最新购买 10 ADA 不会启动。这是在文件中测试的

  • crontab -e
  • sudo crontab -e
  • sudo nano/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:最新购买 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 设置的(你知道,docker 的 aarch64 架构问题......)

docker版本的输出:

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 将自动执行购买而不要求确认。

#Kudos to @MarkoE 帮助我解决了我的问题!

关于Docker Cron 不启动 : "unknown flag: --rm",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69472370/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com