我正在docker-compose.yml中使用环境值。
Dockerfile:
FROM node:8
RUN apt-get update -y \
&& apt-get install -y apache2 \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /home/node/client
COPY client /home/node/client
WORKDIR /home/node/client
RUN npm install bower grunt-cli -g .
RUN npm install \
&& bower install --allow-root
ADD frontend/files-frond/000-default.conf /etc/apache2/sites-enabled/000-default.conf
ADD frontend/files-frond/Settings.js ajeesh/config/Settings.js
COPY frontend/entrypoint.sh /root/entrypoint.sh
RUN chmod 0755 /root/entrypoint.sh
ENTRYPOINT ["/root/entrypoint.sh"]
CMD ["grunt"]
这是我的entrypoint.sh文件
#!/bin/bash
set -xe
sed -i "s/SITE_URL/$SITE_URL/g" /etc/apache2/sites-enabled/000-default.conf
echo "Restoring docker-compatible configs"
declare -A array
array=(
[SITE_URL]=$SITE_URL
[NODE_URL]=$NODE_URL
[EXT_ID]=$EXT_ID
[ZONENAME]=$ZONENAME
[SMART_IP]=$SMART_IP
[MIX_TOKEN]=$MIX_TOKEN
)
if [[ -z $SITE_URL || -z $NODE_URL || -z $EXT_ID || -z $ZONENAME || -z $SMART_IP || -z $MIX_TOKEN ]]; then
echo "Warning: Please make sure the environment provided correctly"
else
for ENV in ${!array[@]}; do
echo "$ENV:${array[$ENV]}"
sed -i "s/$ENV/${array[$ENV]}/g" /home/node/client/ajeesh/config/Settings.js
done
fi
service apache2 start
pushd /home/node/client
exec "$@"
popd
但是执行grunt命令后,我的前端容器已经存在
这是容器中的日志
Running "cssmin:target" (cssmin) task
>> 1 file created. 27.62 kB → 18.81 kB
Running "imagemin:dynamic" (imagemin) task
Minified 544 images (saved 1.52 MB)
Done, without errors.
root@ajeesh-desktop:/home/ajeesh/test/_vol#
在我的容器发生故障之后,如何解决此问题?