Initial Commit to docker branch.

This commit is contained in:
whindes 2017-10-12 13:12:34 -07:00
parent b96ffeb1a7
commit ce035ff5e8
5 changed files with 128 additions and 0 deletions

24
Dockerfile Normal file
View File

@ -0,0 +1,24 @@
FROM alpine:3.6
MAINTAINER William Hindes <bhindes@hotmail.com>
ENV GOPATH="/usr/bin"
ENV GOROOT="/usr/lib/go"
RUN apk --update --no-cache add docker sudo bash && \
apk upgrade --update && \
apk add --no-cache --virtual=.build-dependencies ca-certificates python2 wget go make \
autoconf findutils make pkgconf libtool g++ automake linux-headers git && \
wget "https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/linux/amd64/kubectl" -O "/usr/local/bin/kubectl" && \
mkdir -p /usr/bin/src/k8s.io && cd /usr/bin/src/k8s.io && chmod +x /usr/local/bin/kubectl && \
git clone https://github.com/kubernetes/minikube && cd minikube && \
make && mv ./out/minikube /usr/local/bin/minikube && rm -rf /usr/bin/src/k8s.io && rm -rf /tmp/* && \
minikube start --vm-driver none --kubernetes-version v1.7.5 -v 7 --memory 1024 --disk-size 4g && \
apk del .build-dependencies
ADD ./dockerd-entrypoint.sh /usr/local/bin/
ADD ./dockerd-cmd.sh /usr/local/bin/
ADD ./setup-compose /usr/local/bin/
EXPOSE 2375 30000
ENTRYPOINT ["dockerd-entrypoint.sh"]
CMD ["dockerd-cmd.sh"]

73
README.md Normal file
View File

@ -0,0 +1,73 @@
![Docker](https://msopentech.com/wp-content/uploads/docker-logo.png)
# About
Pure alpine linux docker. Docker inside docker.
> [wikipedia.org/wiki/Docker](https://en.wikipedia.org/wiki/Docker_(software))
# Usage
## System Requirements
The ~700Mb image has an already created minkikube instance with 4Gb diskspace and 1Gb RAM.
This is only for experimentation and demo only. Do not use in production. The minikube binary from the official
repository does not work in Alpine and had to be built from source. (See Dockerfile)
## Commandline
Starts a shell ready to docker & minikube
```bash
docker run -ti --privileged whindes/alpine-minikube sh
```
## Minikube
After the commands below navigate to http://<your_host_docker>:30000/#!/overview?namespace=default
```bash
docker run -ti -p 30000 -p 31920 --rm --privileged whindes/alpine-minikube sh
[Hit Enter] to get the shell prompt
minikube start
kubectl run webserver --image=nginx:alpine
kubectl expose deployment webserver --type=LoadBalancer --port=80
```
## Daemon
```bash
docker run --name alpine-docker -p 2375:2375 --privileged -d whindes/alpine-minikube
```
To start a shell in your new container.
```bash
docker exec -ti alpine-docker /bin/sh
```
## Inside the container shell
Now you can start containers inside your alpine-docker container.
```bash
docker run -d elasticsearch
docker images
docker ps -a
docker volume ls
```
## Docker-compose
If you need docker-compose inside your alpine-docker container.
```bash
setup-compose
docker-compose up
```
## Remote docker
Set your client system variables and go
```bash
export DOCKER_API_VERSION=1.23
export DOCKER_HOST='tcp://127.0.0.1:2375'
docker ps
docker-compose up
```

3
dockerd-cmd.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
echo "Starting Docker Daemon"
docker daemon --host=unix:///var/run/docker.sock --host=tcp://0.0.0.0:2375 --storage-driver=vfs

22
dockerd-entrypoint.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/sh
#clean pid after unexpected kill
if [ -f "/var/run/docker.pid" ]; then
rm -rf /var/run/docker.pid
fi
# Add docker daemon as command if needed
if [[ "$1" != 'dockerd-cmd.sh' ]]; then
echo "Starting Docker Daemon"
docker daemon \
--host=unix:///var/run/docker.sock \
--host=tcp://0.0.0.0:2375 \
--storage-driver=vfs &
fi
# set docker settings
echo "export DOCKER_HOST='tcp://127.0.0.1:2375'" >> /etc/profile
# reread all config
source /etc/profile
exec "$@"

6
setup-compose Normal file
View File

@ -0,0 +1,6 @@
#!/bin/sh
apk add --update openssl
wget https://github.com/docker/compose/releases/download/1..16.1/run.sh -O /usr/local/bin/docker-compose
sed -i "s/\/bin\/bash/\/bin\/sh/g" /usr/local/bin/docker-compose
chmod a+x /usr/local/bin/docker-compose
docker-compose --help