【发布时间】:2019-03-08 13:27:44
【问题描述】:
所以,我有一个我测试过的 Docker 构建命令,效果很好
docker build \
-t app \
--no-cache --network host \
--build argssh_private_key="$(cat ~/.ssh/id_rsa)"\
--build-arg python_version="3.6.8" -f Dockerfile .
为了减轻团队学习 Docker 的痛苦,我将一些命令(构建、启动、停止)封装在 Makefile 中。但是,在 Makefile 中,我需要通过修改来稍微更改命令
$(cat ~/.ssh/id_rsa)
到
$(shell cat ~/.ssh/id_rsa)
当我执行以下操作时:
make build
我收到以下消息:
Step 13/20 : RUN git clone --depth 1 "${git_user}@${git_host}:${git_repo}" app
---> Running in d2eb41a71315
Cloning into 'app'...
Warning: Permanently added the ECDSA host key for IP address [ip_address] to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
但是,从命令行执行时,我没有遇到同样的问题。我认为这与调用“cat”命令的方式有关,但是我不知道解决方法。
有什么想法吗?
生成文件:
APP_NAME=ccs_data_pipeline
DATA?="${HOME}/data"
DOCKER_FILE=Dockerfile
PYTHON_VERSION?=3.6.8
SRC?=$(shell dirname `pwd`)
PRIVATE_KEY?=$(shell echo $(shell cat ~/.ssh/id_rsa))
build: ## Build container for ccs data pipeline
docker build \
-t $(APP_NAME) \
--no-cache --network host \
--build-arg ssh_private_key="$(PRIVATE_KEY)" \
--build-arg python_version="$(PYTHON_VERSION)" \
-f $(DOCKER_FILE) .
start: ## Start the docker container
docker run \
-it -v $(DATA):/data \
--network host \
--rm \
--name="$(APP_NAME)" $(APP_NAME)
stop: ## Stop the docker container
docker stop $(APP_NAME); \
docker rm $(APP_NAME)
【问题讨论】:
标签: bash makefile dockerfile