Dockerfile 自动 运行 passenger 从 Rails 开始
Dockerfile automatically run passenger start with Rails
我已经用 docker 构建了一个 Rails
镜像,但现在我不知道如何使用 Dockerfile 来设置 passenger
。
我的 Dockerfile
现在是
FROM username/my_app:latest
WORKDIR /my_app
# Expose port 3000 to the Docker host, so we can access it from the outside.
EXPOSE 3000
现在我必须先运行容器,然后像这样执行passenger
命令。
docker run -it -p 4321:3000 \
--name my_app \
username/my_app
然后输入
docker exec -itd my_app /bin/bash -c -l "whenever -iw"
docker exec -it my_app /bin/bash -c -l "passenger start"
我终于可以在 http://localhost:4321
中访问我的应用程序了
有没有办法只使用docker run ....
自动启动我的应用程序并打开passenger start
?
我试过了,但好像不行。
FROM username/my_app:latest
WORKDIR /my_app
RUN whenever -iw
RUN passenger start
# Expose port 3000 to the Docker host, so we can access it from the outside.
EXPOSE 3000
使用ENTRYPOINT
启动容器后执行命令。
FROM username/my_app:latest
WORKDIR /my_app
# Expose port 3000 to the Docker host, so we can access it from the outside.
EXPOSE 3000
ENTRYPOINT ["whenever -iw && passenger start "]
有关 ENTRYPOINT
的更多信息,请参阅以下链接:
我已经用 docker 构建了一个 Rails
镜像,但现在我不知道如何使用 Dockerfile 来设置 passenger
。
我的 Dockerfile
现在是
FROM username/my_app:latest
WORKDIR /my_app
# Expose port 3000 to the Docker host, so we can access it from the outside.
EXPOSE 3000
现在我必须先运行容器,然后像这样执行passenger
命令。
docker run -it -p 4321:3000 \
--name my_app \
username/my_app
然后输入
docker exec -itd my_app /bin/bash -c -l "whenever -iw"
docker exec -it my_app /bin/bash -c -l "passenger start"
我终于可以在 http://localhost:4321
中访问我的应用程序了有没有办法只使用docker run ....
自动启动我的应用程序并打开passenger start
?
我试过了,但好像不行。
FROM username/my_app:latest
WORKDIR /my_app
RUN whenever -iw
RUN passenger start
# Expose port 3000 to the Docker host, so we can access it from the outside.
EXPOSE 3000
使用ENTRYPOINT
启动容器后执行命令。
FROM username/my_app:latest
WORKDIR /my_app
# Expose port 3000 to the Docker host, so we can access it from the outside.
EXPOSE 3000
ENTRYPOINT ["whenever -iw && passenger start "]
有关 ENTRYPOINT
的更多信息,请参阅以下链接: