The sed command does inline updates to the /etc/sudoers file to allow foo and root users passwordless access to the sudo group.The home directory is set to /home/foo.The uid and gid is set to the value of 999.The user foo is added to the both the foo and sudo group.Sed -i /etc/sudoers -re 's/^#includedir.*/# **Removed the include directive** #"/g' & \Įcho "foo ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers & \Įcho "Customized the sudoers file for passwordless access to the foo user!" & \ Sed -i /etc/sudoers -re 's/^root.*/root ALL=(ALL:ALL) NOPASSWD: ALL/g' & \ Sed -i /etc/sudoers -re 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/g' & \ Groupadd -g 999 foo & useradd -u 999 -g foo -G sudo -m -s /bin/bash foo & \ Here's how I setup a non-root user with the base image of ubuntu:18.04: RUN \ It is much quicker but takes more space to not compress, using: docker save container | dir/file.tar Which you can restore to another Docker install using: gzcat /dir/ | docker load To export a copy of the image: docker save container | gzip > /dir/ To copy from a running container: docker cp :/file/path/within/container /host/path/target To start a container that isn't running and connect as root: docker run -ti -u root -entrypoint=/bin/bash image_id_or_name -s To roll back to a previous image version (warning: this deletes history rather than appends to the end, so to keep a reference to the current image, tag it first using the optional step): docker history image_nameĭocker tag latest_image_id my_descriptive_tag_name # optionalĭocker tag desired_history_image_id image_name To save your changes so that they are still there when you next launch the container (or docker-compose cluster): docker commit container_id image_name You can also connect using its ID, rather than its name, by finding it with: docker ps -l For anyone who has this issue with an already running container, and they don't necessarily want to rebuild, the following command connects to a running container with root privileges: docker exec -ti -u root container_name bash
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |