Showing posts with label docker. Show all posts
Showing posts with label docker. Show all posts

Friday, 21 November 2014

simple Dockerfile example1

1. cat Dockerfile

FROM cassandra
ADD start.sh /start.sh # to copy the file into
CMD ["bash", "./start.sh"]
EXPOSE 9160
EXPOSE 9042
EXPOSE 7000
EXPOSE 44478
EXPOSE 7199


2. cat start.sh
#!/bin/bash
service cassandra start
while true; do sleep 60; done  # Not sure any other best way for now

3. 
docker build -t="runcassandra" .     # this will create an image named runcassandra

4.
docker run -d -P --name cass1 runcassandra

NOTE: The cassandra will be up and will listen to rest of the port. But key thing is when you use EXPOSE, these ports get use for container to container communication ***ONLY***,  as per my current understanding, and this is what I found from the documentation too.


Wednesday, 19 November 2014

copy file from host to the docker container

copy file from host to the docker container:

Steps:

1: Get container name or short container id :
  1a. docker ps
  1b. Get full container id
docker inspect -f '{{.Id}}' SHORT_CONTAINER_ID-or-CONTAINER_NAME

  1c. copy file :
  sudo cp path-file-host /var/lib/docker/aufs/mnt/FULL_CONTAINER_ID/PATH-NEW-FILE


EXAMPLE :

$docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
450b4b6a87e7 amit/ssh:latest /usr/sbin/sshd -D cranky_pare

$docker inspect -f '{{.Id}}' cranky_pare

or

$docker inspect -f '{{.Id}}' 450b4b6a87e7
450b4b6a87e734ba68d1c077de5d3d9ac617b1b9b6e829fe28c917abf1dce44f

From your docker server:
$ sudo cp file.txt /var/lib/docker/aufs/mnt/450b4b6a87e734ba68d1c077de5d3d9ac617b1b9b6e829fe28c917abf1dce44f/root/file.txt


docker networking with hack part1

I found the easy way of having multiple container running on the same host, bind with the host IP, then assign multiple IP the same interface of the host.

1. How do I bind multiple IP to the same interface:

amund@prod-docker-app01:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 172.22.19.75
netmask 255.255.255.0
network 172.22.19.0
broadcast 172.22.19.255
gateway 172.22.19.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 172.17.0.10 172.17.0.14 172.27.2.20
dns-search example.com example.net example.in

# bind-ed one assigned IP
auto eth0:0
iface eth0:0 inet static
        address 172.22.19.76
        netmask 255.255.255.0
        network 172.22.19.0
        broadcast 172.22.19.255
        gateway 172.22.19.1
        # dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 172.17.0.10 172.17.0.14 172.27.2.20
dns-search example.com example.net example.in

# bind-ed second assigned IP
auto eth0:1
iface eth0:1 inet static
        address 172.22.19.77
        netmask 255.255.255.0
        network 172.22.19.0
        broadcast 172.22.19.255
        gateway 172.22.19.1
        # dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 172.17.0.10 172.17.0.14 172.27.2.20
dns-search example.com example.net example.in

# bind-ed thired assigned IP
auto eth0:2
iface eth0:2 inet static
        address 172.22.19.78
        netmask 255.255.255.0
        network 172.22.19.0
        broadcast 172.22.19.255
        gateway 172.22.19.1
        # dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 172.17.0.10 172.17.0.14 172.27.2.20
dns-search example.com example.net example.in

2. If you are using remote host, good to reboot once and check your network update.


Thursday, 30 October 2014

Docker design doc1


A sample docker design doc, how we can implement docker in the production environment. Will update other docker command later in the blog.

The ports are just for example. Note: we can run the keepalived and haproxy on the same server where docker is running, just for simplicity I draw at different server.

Following image's original pdf link:
https://drive.google.com/file/d/0B02LZ59YLdSdaTBlVGdmX0RlWU0/view?usp=sharing