英文:
Passing Makefile variable to docker-compose is resulting in a "unknown shorthand flag" error
问题
我有一个Makefile
,我用它来帮助我们的程序员轻松设置环境。目前,我正在编写一个Makefile
来将IMAGE
标签传递给docker-compose
命令,但我一直收到一个unknown shorthand flag
错误,我无法弄清楚原因。
我的Makefile
如下:
.PHONY: all
ARCH = $(shell uname -m)
start:
if [ "$(ARCH)" = "x86_64" ]; then \
IMAGE_ARCH="amd64"; \
elif [ "$(ARCH)" = "aarch64" ]; then \
IMAGE_ARCH="arm64"; \
else \
echo "Unknown architecture: $(ARCH)"; \
fi
docker-compose up -d -e IMAGE=$IMAGE_ARCH
错误信息是:
unknown shorthand flag: 'e' in -e
英文:
I have a Makefile
which I use to help our programmers get easily setup. At present I am writing one to pass an IMAGE
tag to the docker-compose command, but I keep getting a unknown shorthand flag
and I cant figure out why.
My Makefile
is as follows;
.PHONY: all
ARCH = $(shell uname -m)
start:
if [ "$(ARCH)" = "x86_64" ]; then \
IMAGE_ARCH="amd64"; \
elif [ "$(ARCH)" = "aarch64" ]; then \
IMAGE_ARCH="arm64"; \
else \
echo "Unknown architecture: $(ARCH)"; \
fi
docker-compose up -d -e IMAGE=$IMAGE_ARCH
The error is;
unknown shorthand flag: 'e' in -e
答案1
得分: 1
docker-compose
没有-e
选项。
你可以这样运行:
.PHONY: all
ARCH := $(shell uname -m)
start:
if [ "$(ARCH)" = "x86_64" ]; then \
IMAGE_ARCH="amd64"; \
elif [ "$(ARCH)" = "aarch64" ]; then \
IMAGE_ARCH="arm64"; \
else \
echo "Unknown architecture: $(ARCH)"; \
fi; \
IMAGE=$$IMAGE_ARCH docker-compose up -d
docker-compose
命令需要放在与[if
]相同的块中,以便使用$IMAGE_ARCH。
英文:
docker-compose
has no -e
option.
You can run this way :
.PHONY: all
ARCH := $(shell uname -m)
start:
if [ "$(ARCH)" = "x86_64" ]; then \
IMAGE_ARCH="amd64"; \
elif [ "$(ARCH)" = "aarch64" ]; then \
IMAGE_ARCH="arm64"; \
else \
echo "Unknown architecture: $(ARCH)"; \
fi; \
IMAGE=$$IMAGE_ARCH docker-compose up -d
docker-compose
command needs to be put in the same block as [if
] in order to use $IMAGE_ARCH.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论