Docker - kanuku/misc GitHub Wiki
how to delete images
15 docker tips
Linking containers
##### See how much space your docker container is using
sudo du -d 2 -h /var/lib/docker/devicemapper | grep `docker inspect -f "{{.Id}}" fashion-advice-master`
Mounts /tmp/jenkins folder from the host machine to /var/jenkins_home on the host machine.
docker run -it -v /tmp/jenkins:/var/jenkins_home busybox
#### Removes the current image
rm .boot2docker/boot2docker.iso
#### To log into the container
docker exec -it <container_name> bash
# Or
docker run -i -t -entrypoint="/bin/bash" postgres
#### To see the loggings
docker logs <containername>
#### Extracting image name from docker container
docker inspect --format "{{ .Config.Image }}" container name
##### Find out which docker version created the image
docker run jenkins cat /etc/lsb-release
# Upgrading docker to latest release
wget -qO- https://get.docker.com/ | sh
Known problems
Errors with device mapper when building without aufs
# I switched from the default 'devicemapper' driver to 'aufs' and so far, no more problems..
sudo apt-get install linux-image-extra-$(uname -r) aufs-tools
sudo service docker restart
# @ahromis @kytwb you should try using aufs and see if it clears it up for you.
# Would be good to have more data points on this..
Insecure registry
For Docker 1.3.1 and later, docker push to this development registry
may fail without SSL certificate support. Restart docker with an
--insecure-registry flag.
For boot2docker 1.3.1 for example, add
EXTRA_ARGS="--insecure-registry 192.168.59.103:5000" to
/var/lib/boot2docker/profile and restart docker with sudo
/etc/init.d/docker restart.
Certificate gets invalidated for certain IP
$ docker ps
An error occurred trying to connect: Get https://192.168.59.103:2376/v1.19/images/json: x509: certificate is valid for 127.0.0.1, 10.0.2.15, not 192.168.59.103
## Fix it with
$ boot2docker ssh 'sudo /etc/init.d/docker restart'
ssh -i cd-jenkinses.pem [email protected]
How to remove all old containers
# Containers older than one week shall be removed
docker ps -a | grep 'Exited' | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm
How to create image for java application
FROM openjdk:11-jre-slim
VOLUME /tmp
EXPOSE 8080
ARG JAR_FILE=target/my-service.jar
#OR ARG JAR_FILE=target/my-service-*.jar
ADD ${JAR_FILE} service.jar
CMD java $JVM_OPTS -jar /service.jar
Dockerfile (END)