1
SO post about replicating UID/GID in container from hostと同様ですが、レプリケートUIDとGIDを持つユーザーでイメージをどのように構築しますか?できれば、ドッカーファイルでどうやってやるの?DockerfileはホストユーザーのUIDとGIDをイメージに複製します
私はbashスクリプトでそれを行うことができます。
#!/bin/bash
# current uid and gid
curr_uid=`id -u`
curr_gid=`id -g`
# create bb.dockerfile:
cat <<EOF1> bb.dockerfile
FROM ubuntu:xenial-20170214
ARG UNAME=testuser
EOF1
echo ARG UID=${curr_uid} >> bb.dockerfile
echo ARG GID=${curr_gid} >> bb.dockerfile
cat <<EOF2>> bb.dockerfile
RUN groupadd -g \$GID \$UNAME
RUN useradd -m -u \$UID -g \$GID -s /bin/bash \$UNAME
USER \$UNAME
CMD /bin/bash
EOF2
docker build -f bb.dockerfile -t testimg .
このbashは、次のようにドッキングウィンドウのファイルを生成し、その上に構築されます。私が求めている何
FROM ubuntu:xenial-20170214
ARG UNAME=testuser
ARG UID=1982
ARG GID=1982
RUN groupadd -g $GID $UNAME
RUN useradd -m -u $UID -g $GID -s /bin/bash $UNAME
USER $UNAME
CMD /bin/bash
は、dockerfileからハードコードされたホストUID 1982およびGID 1982を削除することです。
を!どうもありがとう! – minghua