Skip to content

Instantly share code, notes, and snippets.

@simoncowie
Last active March 5, 2018 00:50
Show Gist options
  • Save simoncowie/b8a720caa4dec35820d547de95b92822 to your computer and use it in GitHub Desktop.
Save simoncowie/b8a720caa4dec35820d547de95b92822 to your computer and use it in GitHub Desktop.
Docker bits and pieces
# Access to localhost through docker.for.win.localhost
# A hack to hit that IP as localhost
# note that ip may change so could be fragile?
docker run --add-host localhost:192.168.65.2 ... etc
#dynamically as part of dockerfile
#Ugly but working for local stuff.
ENTRYPOINT echo "$(dig +short docker.for.win.host.internal) localhost" >> /etc/hosts && exec python ./end2end_dev.py
#Docker output , no wrap, less allows horizontal scrolling
λ: docker ps -a | less -S
#follow logs
λ: docker logs x1y2z3 -f
#bash in an image
λ: docker exec -it 1103e bash
# various ways to debug a container, but this is useful to keep it running:
ENTRYPOINT ["/bin/bash", "-c", "while true; do sleep 10; date; done"]
# or
ENTRYPOINT ["bash", "-c", "sleep 1d"]
# set NZ timezone for jenkins container
# This assumes the image has TZ info in /usr/share/zoneinfo/
ENV TZ=Pacific/Auckland
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Though maybe this is a fuller solution
ENV TZ Asia/Kuala_Lumpur
RUN echo $TZ > /etc/timezone && \
apt-get update && apt-get install -y tzdata && \
rm /etc/localtime && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata && \
apt-get clean
# OR, mount at runtime
# docker run -v /etc/localtime:/etc/localtime ...
# Also at runtime, (for vanilla unix) just set TZ env variable?
# sudo docker run -i -t -e TZ=Europe/London centos /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment