Skip to content

Instantly share code, notes, and snippets.

@toricls
Last active April 26, 2023 23:49
Show Gist options
  • Save toricls/e17c7f2f1c024cc368dcd860804194f5 to your computer and use it in GitHub Desktop.
Save toricls/e17c7f2f1c024cc368dcd860804194f5 to your computer and use it in GitHub Desktop.
Docker-in-Docker with Amazon Linux 2 Container
FROM amazonlinux:2
RUN yum -y update \
# systemd is not a hard requirement for Amazon ECS Anywhere, but the installation script currently only supports systemd to run.
# Amazon ECS Anywhere can be used without systemd, if you set up your nodes and register them into your ECS cluster **without** the installation script.
&& yum -y install systemd \
&& yum clean all
RUN cd /lib/systemd/system/sysinit.target.wants/; \
for i in *; do [ $i = systemd-tmpfiles-setup.service ] || rm -f $i; done
RUN rm -f /lib/systemd/system/multi-user.target.wants/* \
/etc/systemd/system/*.wants/* \
/lib/systemd/system/local-fs.target.wants/* \
/lib/systemd/system/sockets.target.wants/*udev* \
/lib/systemd/system/sockets.target.wants/*initctl* \
/lib/systemd/system/basic.target.wants/* \
/lib/systemd/system/anaconda.target.wants/*
RUN amazon-linux-extras install epel docker && \
systemctl enable docker
CMD ["/usr/sbin/init"]
@toricls
Copy link
Author

toricls commented Jul 16, 2021

docker build -t ecs-anywhere-node .

docker run -d --privileged \
  --name ecs-anywhere \
  -p 8080-8090:8080-8090 ecs-anywhere-node:latest

docker exec -it ecs-anywhere /bin/bash

@tjtaill
Copy link

tjtaill commented Apr 26, 2023

Been looking to do this all week unfortunately your solution doesn't seem to work better than any other

docker image ls

gives the usual

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

@toricls
Copy link
Author

toricls commented Apr 26, 2023

@tjtaill According to the error message you got, it looks you need to run Docker daemon beforehand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment