Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Last active January 18, 2024 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrichardsz/a403b05f78b71151d8aa204eb5b74f51 to your computer and use it in GitHub Desktop.
Save jrichardsz/a403b05f78b71151d8aa204eb5b74f51 to your computer and use it in GitHub Desktop.
docker aws snippets , dockeraws dockerawssnippet, aws cli , awscli

docker run

docker run -it --entrypoint /bin/bash amazon/aws-cli

Dockerfile v1

FROM amazon/aws-cli
COPY DockerfileEntryPoint.sh /usr/local/bin/DockerfileEntryPoint.sh
RUN chmod 744 /usr/local/bin/DockerfileEntryPoint.sh
ENTRYPOINT ["DockerfileEntryPoint.sh"]

DockerfileEntryPoint.sh

#!/bin/bash
while true; do    echo "hello";    sleep 2000; done

Dockerfile v2

FROM amazon/aws-cli
RUN echo "#!/bin/bash" >> /usr/local/bin/DockerfileEntryPoint.sh
RUN echo "while true; do    echo \"hello\";    sleep 2000; done" >> /usr/local/bin/DockerfileEntryPoint.sh
RUN chmod 744 /usr/local/bin/DockerfileEntryPoint.sh
ENTRYPOINT ["DockerfileEntryPoint.sh"]

run and enter

docker build  --rm -t aws . && docker run --name aws -d aws && docker logs aws -f
docker exec -it aws bash

You will have a ready to use container with latest aws sdk installed

references

FROM python

# Install AWS CLI
RUN pip install awscli --upgrade --user

# Adding AWS CLI Executable to Path
RUN echo 'export PATH=~/.local/bin:$PATH'>>root/.bashrc

# Install groff to enable AWS CLI command line help
RUN apt-get update \
    && apt-get --assume-yes install groff
    
RUN echo "#!/bin/bash" >> /usr/local/bin/DockerfileEntryPoint.sh
RUN echo "while true; do    echo \"hello\";    sleep 2000; done" >> /usr/local/bin/DockerfileEntryPoint.sh
RUN chmod 744 /usr/local/bin/DockerfileEntryPoint.sh
ENTRYPOINT ["DockerfileEntryPoint.sh"]

run and enter

docker build  --rm -t aws . && docker run --name aws -d aws && docker logs aws -f
docker exec -it aws bash

references

FROM amazon/aws-cli
ENTRYPOINT ["python", "-m", "SimpleHTTPServer", "8000"]
docker exec -it aws bash
while read name
do echo ">>>>$name"
echo "" > $(docker inspect --format='{{.LogPath}}' $name)
docker logs $name
done <<< $(docker ps --format "table {{.Names}}" | tail -n +2 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment