刚启动容器时,如何运行Echo Hello World
我有一个如下:
FROM kong
USER 0
RUN mkdir -p /kong/declarative/
COPY declarative/kong.yml /kong/declarative/
# COPY docker-entrypoint.sh /docker-entrypoint.sh
# RUN ["chmod", "+x", "/docker-entrypoint.sh"]
# ENTRYPOINT ["/docker-entrypoint.sh"]
RUN cp /etc/kong/kong.conf.default /etc/kong/kong.conf
docker-entrypoint.sh
#!/usr/bin/env bash
echo "Hello World"
我也有一个docker-compose文件。
version: "3.8"
networks:
kong-net:
name: kong-net
driver: bridge
ipam:
config:
- subnet: 172.1.1.0/24
services:
kong:
container_name: kong
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
networks:
kong-net:
ipv4_address: 172.1.1.40
healthcheck:
test: [ “CMD”, “curl”, “-f”, “http://kong:8000” ]
interval: 5s
timeout: 2s
retries: 15
environment:
- KONG_DATABASE=off
- KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
- KONG_PROXY_ACCESS_LOG=/dev/stdout
- KONG_ADMIN_ACCESS_LOG=/dev/stdout
- KONG_PROXY_ERROR_LOG=/dev/stderr
- KONG_ADMIN_ERROR_LOG=/dev/stderr
- KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yml
- MYNAME=amin
ports:
- "8444:8444"
- "80:8000"
- "443:8443"
- "8001:8001"
我还有一个docker-compose文件,如下面,当我运行docker-composes-build
时, 它按预期运行良好,但是如果我输入docker-file 中的三行和运行docker-compose-build
这是结果
我做错了什么?我应该如何解决? 在启动之前,我需要在运行阶段的Docker容器中运行一个命令。我应该怎么做?
I have a docker file as below:
FROM kong
USER 0
RUN mkdir -p /kong/declarative/
COPY declarative/kong.yml /kong/declarative/
# COPY docker-entrypoint.sh /docker-entrypoint.sh
# RUN ["chmod", "+x", "/docker-entrypoint.sh"]
# ENTRYPOINT ["/docker-entrypoint.sh"]
RUN cp /etc/kong/kong.conf.default /etc/kong/kong.conf
and the docker-entrypoint.sh
is
#!/usr/bin/env bash
echo "Hello World"
also I have a docker-compose file as below
version: "3.8"
networks:
kong-net:
name: kong-net
driver: bridge
ipam:
config:
- subnet: 172.1.1.0/24
services:
kong:
container_name: kong
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
networks:
kong-net:
ipv4_address: 172.1.1.40
healthcheck:
test: [ “CMD”, “curl”, “-f”, “http://kong:8000” ]
interval: 5s
timeout: 2s
retries: 15
environment:
- KONG_DATABASE=off
- KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
- KONG_PROXY_ACCESS_LOG=/dev/stdout
- KONG_ADMIN_ACCESS_LOG=/dev/stdout
- KONG_PROXY_ERROR_LOG=/dev/stderr
- KONG_ADMIN_ERROR_LOG=/dev/stderr
- KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yml
- MYNAME=amin
ports:
- "8444:8444"
- "80:8000"
- "443:8443"
- "8001:8001"
When I run docker-compose up --build
it runs fine as expected but if I uncomment the three lines in the docker-file and run docker-compose up --build
this is the result
What is it that I am doing wrong? How should I fix it?
I need to run a command in the docker container in the run stage before it is started. How should I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论