Created
November 24, 2017 02:04
-
-
Save notae/3105d0d80c26821d300b93827a913b38 to your computer and use it in GitHub Desktop.
Personalization of an existing docker image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IMAGE=local/ubuntu-dev:16.04 | |
NAME=mydocker | |
LANG=C.UTF-8 | |
DIR=`dirname $0` | |
SETUP=mydocker-setup | |
SETUP_CMD=/root/${SETUP} | |
HOST_UID=`id -u` | |
HOST_GID=`id -g` | |
HOST_UNAME=`id -un` | |
docker run -it --rm \ | |
--name ${NAME} \ | |
--mount "type=bind,src=${HOME},dst=${HOME}" \ | |
--mount "type=bind,src=${DIR}/${SETUP},dst=${SETUP_CMD}" \ | |
-u root \ | |
-w ${HOME} \ | |
-e HOME=${HOME} \ | |
-e LANG=${LANG} \ | |
-e HOST_UID=${HOST_UID} \ | |
-e HOST_GID=${HOST_GID} \ | |
-e HOST_UNAME=${HOST_UNAME} \ | |
${IMAGE} \ | |
${SETUP_CMD} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "${HOST_UNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user | |
groupadd -o -g ${HOST_GID} ${HOST_UNAME} | |
useradd -o -u ${HOST_UID} -g ${HOST_GID} ${HOST_UNAME} | |
exec su - ${HOST_UNAME} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment