dockerizing an application on Mac OS X
$$:~ kv$ boot2docker start Waiting for VM and Docker daemon to start... ...................ooo Started. Writing /Users/kvantum/.boot2docker/certs/boot2docker-vm/ca.pem Writing /Users/kvantum/.boot2docker/certs/boot2docker-vm/cert.pem Writing /Users/kvantum/.boot2docker/certs/boot2docker-vm/key.pem Your environment variables are already set correctly. $$:~ kv$ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu 14.04 b39b81afc8ca 11 days ago 188.3 MB hello-world latest e45a5af57b00 3 weeks ago 910 B
After this, I ran the following command:
docker run -t -i ubuntu:14.04 /bin/bash
Inside the container, I installed zeromq, and started a zeromq server on port 5555 using tcp.
My questions are following:
If I exit out of the container, will it save all the work I do inside it?
I have no idea how to connect to the server running on port 5555. I read something about exposing a port, but I am not sure how to go about doing that. I did an ifconfig inside the container, and tried to connect to the server from the host like this:
$$:~ kv$ ./zmq_client tcp://container_ip:5555
This did not work. Can someone please lists the steps I need to take in order to connect to the server running within the container.
For completion sake, I am providing the list of my environment variables:
TERM_PROGRAM=Apple_Terminal TERM=xterm-256color SHELL=/bin/bash TMPDIR=/var/folders/km/5kbpdx4s7cg4rmyc6d5q9l9r0000gq/T/ DOCKER_HOST=tcp://192.168.109.103:2376 Apple_PubSub_Socket_Render=/tmp/launch-1tWMHJ/Render TERM_PROGRAM_VERSION=326 OLDPWD=/Users TERM_SESSION_ID=262CBC8B-0A74-4B70-9F28-D9FA51FF713C USER=kv SSH_AUTH_SOCK=/tmp/launch-ZTWNGL/Listeners __CF_USER_TEXT_ENCODING=0x1F7:0:0 DOCKER_TLS_VERIFY=1 __CHECKFIX1436934=1 PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin PWD=/Users/kv DOCKER_CERT_PATH=/Users/kv/.boot2docker/certs/boot2docker-vm HOME=/Users/kv SHLVL=1 LOGNAME=kv LC_CTYPE=UTF-8 DISPLAY=/tmp/launch-rco9zt/org.macosforge.xquartz:0 _=/usr/bin/env
One last question I have is about code performance. So within my Mac OS X, I have a docker container running (which runs Ubuntu). If I run the application, like a zeromq based server inside the container, will it not be slower as compared to running it on Mac OS X directly. Please explain the benefits of using docker in such a scenario..
One Solution collect form web for “dockerizing an application on Mac OS X”
You should really do some more reading and research before turning to SO, then ask about anything you can’t figure out. But:
No. If the container is “exited” you can restart it and your files will still be there, but once it is removed your files are gone. You can use
docker committo save them to an image, but the best bet is to use a Dockerfile.
docker run -p 5000:8000 imagewill expose port 8000 in the container as port 5000 on the host.
Yes, it will be slower due to the boot2docker VM. It would not be slower if you were running on a Linux host. The advantage is that zeromq is now running in an isolated container with all its dependencies.