我有一个docker-compose.yml
配置。其中一个容器中有一个Tomcat服务器,该服务器在webapps
目录中部署了一些默认的.war
文件。
我希望能够传递(覆盖)要部署的war
存档文件,该文件位于主机上。我认为最好的方法是有能力以某种方式切换/覆盖启动docker-compose
:默认情况下,我想运行容器内部的Web应用程序(war
文件),但如果需要的话,我希望能够挂载来自我的主机的目录(例如在开发/调试期间)。
目前,在我的docker-compose.yml
中有以下行,如果需要默认值,则已注释掉。
volumes:
# By default, there is the latest version of the application already present in the container
# If you want to provider the container with your own .war file, uncomment the following line
# - ./application/webapps:/usr/local/tomcat/webapps
有没有更好的方法来实现这个目标?
if [ "$(uname -s)" == "Darwin" ]; then env_file="env/envMacOS" dc_extend="" else env_file="env/envUbuntu" dc_extend="-f docker-compose-linux.yml" fi # 复制docker所需的文件,但不在git中,因为它们是重复的 cp ${env_file} .env cp ../requirements.txt . echo "***** ENV ${env_file} ****" docker-compose up -d --build htpc docker-compose -f docker-compose.yml ${dc_extend} up -d ```
- Rob Raymond