boot2docker startup script to mount local shared folder with host

/var/lib/boot2docker/bootlocal.sh fits your need probably, it will be run by initial script /opt/bootscripts.sh And bootscripts.sh will also put the output into the /var/log/bootlocal.log, see segment below (boot2docker 1.3.1 version) # Allow local HD customisation if [ -e /var/lib/boot2docker/bootlocal.sh ]; then /var/lib/boot2docker/bootlocal.sh > /var/log/bootlocal.log 2>&1 & fi One use case for me is I usually put … Read more

Connect to a Service running inside a docker container from outside

If your container has mapped its port on the VM 12008 port, you would need to make sure you have port forwarded 12008 in your VirtualBox connection settings, as I mention in “How to connect mysql workbench to running mysql inside docker?“ VBoxManage controlvm “boot2docker-vm” –natpf1 “tcp-port12008 ,tcp,,12008,,12008” VBoxManage controlvm “boot2docker-vm” –natpf1 “udp-port12008 ,udp,,12008,,12008”

Not enough entropy to support /dev/random in docker containers running in boot2docker

I just realized, that it is simple as mounting /dev/urandom from the host as /dev/random into the container: $ docker run -v /dev/urandom:/dev/random … The result is as expected: $ docker run –rm -it -v /dev/urandom:/dev/random ubuntu dd if=/dev/random of=/dev/null bs=1 count=1024 1024+0 records in 1024+0 records out 1024 bytes (1.0 kB) copied, 0.00223239 s, … Read more

How do I mount a Docker volume while using a Windows host?

It is possible the / is interpreted as an option by the CMD Windows shell. Try first a docker-machine ssh default, in order to open an ssh session in your VM. From there try the docker run again: docker run -v /c/Users/phisch/dev/htdocs:/var/www phisch:dev As commented by thaJeztah in issue 18290: You could consider using docker-compose; … Read more

Port forwarding in docker-machine?

You can still access the VBoxmanage.exe command from the VirtualBox used by docker machine: VBoxManage controlvm “boot2docker-vm” natpf1 “tcp-port27017,tcp,,27017,,27017”; Use docker-machine info to get the name of your vm. use modifyvm if the vm isn’t started yet. See a practical example in this answer. That is the current workaround, pending the possibility to pass argument … Read more

How can I use a local file on container?

Yes, you can do this. What you are describing is a bind mount. See https://docs.docker.com/storage/bind-mounts/ for documentation on the subject. For example, if I want to mount a folder from my home directory into /mnt/mydata in a container, I can do: docker run -v /Users/andy/mydata:/mnt/mydata myimage Now, /mnt/mydata inside the container will have access to … Read more

Docker: How to clear the logs properly for a Docker container?

First the bad answer. From this question there’s a one-liner that you can run: echo “” > $(docker inspect –format=”{{.LogPath}}” <container_name_or_id>) instead of echo, there’s the simpler: : > $(docker inspect –format=”{{.LogPath}}” <container_name_or_id>) or there’s the truncate command: truncate -s 0 $(docker inspect –format=”{{.LogPath}}” <container_name_or_id>) I’m not a big fan of either of those since … Read more