How to setup amazon Linux 2 docker image so it emulates an ec2 instance with an ec2-user

Viewed 35

I am trying to get a docker image going for an amazon Linux upgrade project. I would like to do some local testing and was hoping to use docker to emulate an ec2 instance with Linux 2 running.

Does anyone know how to correctly emulate an ec2-user? I don't know what user groups are currently setup in their Linux version.

I would like to be able to use ansible to setup things via ssh with ec2-user keys.

Here is my dockerfile so far...

FROM amazonlinux:2

RUN yum -y upgrade && \
amazon-linux-extras install -y epel && \
yum -y install openssh && \
yum -y install sudo && \    
groupadd -g 1000 ec2-user && \    
useradd -u 1000 -g ec2-user -m ec2-user -G docker && \   
usermod -p "*" ec2-user &&\
su - ec2-user && \
mkdir .ssh && \
chmod 700 .ssh && \
touch .ssh/authorized_keys && \
chmod 600 .ssh/authorized_keys

EXPOSE 80

CMD ["/bin/bash while true; do sleep 1000; done"]

So far it just says that the group docker is not found. Anyone know how to help me with this?

Thanks.

0 Answers
Related