我编写了一个DOCKER文件,使用的是一个私有适应的alpine镜像,其中包含一个nginx服务器。 注意:alpine使用zsh而不是bash。
当在容器中工作时,我希望有一些shell别名可用,如果它们缺失会让我抓狂。因此,我将一个小的预先准备好的文件复制到/root/.profile,这是有效的。我可以查看文件及其内容。但是只有在我手动执行“~/.profile”命令后,该文件才会被加载,然后我的别名才可以使用。
我应该怎么做才能在启动容器并连接到其shell后自动加载我的配置文件?
FROM myprivatealpineimage/base-image-php:7.4.13
ARG TIMEZONE
COPY ./docker/shared/bashrc /root/.profile
COPY ./docker/shared/ /tmp/scripts/
RUN chmod +x -R /tmp/scripts/ \
&& /tmp/scripts/set_timezone.sh ${TIMEZONE}\
&& apk update\
&& apk add --no-cache git
RUN install-ext pecl/apcu pecl/imagick pecl/zip pecl/redis
RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php
WORKDIR /var/www
Dockerfile
中添加了PATH
并通过名称调用该路径中的脚本。 - Saeed Neamati