deliverytore.blogg.se

Add sudo
Add sudo




add sudo

The main idea is that you need to create user that is a root user according to the container. The sed command disables the #includedir directive that would allow any files in subdirectories to override these inline updates.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

#ADD SUDO INSTALL#

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) - note that these changes would not be repeated if you rebuild from scratch: 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






Add sudo