[英]docker-compose execute command
I'm trying to put some commands in my docker-compose
file to be ran in my container and they don't work. 我试图在我的
docker-compose
文件中放置一些命令以在我的容器中运行,但它们不起作用。
I map a volume from host to container where I have a Root certificate, all I want to do is to run this command update-ca-certificates
, so it will updates the directory /etc/ssl/certs with my cert in the container, however it is not happening. 我将一个卷从主机映射到具有根证书的容器,我要做的就是运行此命令
update-ca-certificates
,因此它将使用容器中的证书更新目录/ etc / ssl / certs,但是它没有发生。
I tried to solve this in a Dockerfile and I can see that the command runs, but it seems that the cert is not present there and just appears after I login to the container. 我尝试在Dockerfile中解决此问题,并且可以看到命令正在运行,但是似乎证书不存在,并且仅在我登录到容器后出现。
What I end doing is to get into the container, then I run the needed commands manually. 我最终要做的是进入容器,然后手动运行所需的命令。
This is the piece of my docker-compose
file that I have been trying to use: 这是我一直在尝试使用的
docker-compose
文件的一部分:
build:
context: .
dockerfile: Dockerfile
command: >
sh -c "ls -la /usr/local/share/ca-certificates &&
update-ca-certificates"
security_opt:
- seccomp:unconfined
volumes:
- "c:/certs_for_docker:/usr/local/share/ca-certificates"
In the same way I cannot run apt update
or anything like this, but after connecting to the container with docker exec -it test_alerting_comp /bin/bash
I can pull anything from any repo. 以同样的方式,我无法运行
apt update
或类似的东西,但是使用docker exec -it test_alerting_comp /bin/bash
连接到容器后,我可以从任何存储库中提取任何东西。
My goal is to execute any needed command on building time, so when I login to the container I have already the packages I will use and the Root cert updated, thanks. 我的目标是在构建时执行任何需要的命令,因此,当我登录到容器时,我已经准备好要使用的软件包并更新了根证书,谢谢。
Why dont you do package update/install and copy certificates in the Dockerfile? 为什么不在Dockerfile中打包更新/安装并复制证书?
Dockerfile Dockerfile
...
RUN apt-get update && apt-get -y install whatever
COPY ./local/certificates /usr/local/share/my-certificates
RUN your-command-for-certificates
docker-compose.yml 泊坞窗,compose.yml
version: "3.7"
services:
your-service:
build: ./dir
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.