Question

The task is to complete a file stub '/home/ubuntu/833947-docker-user-context/script.sh' with one or more steps that do...

The task is to complete a file stub '/home/ubuntu/833947-docker-user-context/script.sh' with one or more steps that do following
. Runs a new docker container "my-container" from the "busybox" image(latest tag) in ittaractive background mode. without pseudo-TTY allocation
and under user "nobody"

note:

. The completed solution will be evaluted in a new clean environment. Be sure everything is in the "/home/ubuntu/833947-docker-user-context" folder
. All the tasks should be done within a simple "bash/home/ubuntu/833947-docker-user-context/script.sh" execution
. Docker is already installed
. You have sudo access

Grading

The execution result of "docker exce -i my-container whoami" outputs show "nobody"

Homework Answers

Answer #1

1) script.sh (we are creating a temporary docker file so that we can add logic of user nobody, so temporary docker image is local:local)

echo "FROM scratch" >Dockerfile ## it is expected that your image is having ubuntu image.

echo "COPY --from=busybox:latest /home/ubuntu/833947-docker-user-context /home/ubuntu/833947-docker-user-context" >>Dockerfile

echo "RUN groupadd nobody && useradd --no-user-group --groups nobody --password nobody123 --create-home nobody" >> Dockerfile
echo "USER nobody" >> Dockerfile

echo "ENTRYPOINT [\"tail\", \"-f\", \"/dev/null\"]" >>Dockerfile

docker build -t local:local .

docker container run --name my-container local:local

docker exec -i mycont4 whoami
nobody

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT