Skip to content

Commit

Permalink
update README, add install script
Browse files Browse the repository at this point in the history
  • Loading branch information
BananaWanted authored and BananaWanted committed Jun 1, 2018
1 parent 58b86a0 commit 66c70b1
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ RUN apt-get update \
RUN wget -O dircolors "https://raw.githubusercontent.com/seebi/dircolors-solarized/master/dircolors.ansi-light" \
&& dircolors -b dircolors > /root/.dircolors_source \
&& rm -f dircolors \
&& curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash -s \
&& curl -fsSL "https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh" | bash -s \
&& chsh -s /bin/zsh
COPY zshrc /root/.zshrc
COPY sources.list.* /etc/apt/
Expand Down
74 changes: 46 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,61 @@

A handy ubuntu enviroment in docker.

## What's Inside
- Ubuntu bionic (18.04LTS)
- basic network utils like telnet, ping, etc.
- lsb
- ssh server
- oh my zsh
- docker engine (docker in docker)
- python2 and python3
- ...


## Installation
### Pull from DockerHub
```bash
docker pull 4oranges/dubuntu
# Install command line tools to /usr/local/bin
./install
```

### Or Build it Locally
```bash
git clone https://github.com/4Oranges/Dubuntu.git && cd Dubuntu
./build.sh
```
## Command Line Reference
### `dubuntu-pull`
pull the image from docker hub

### `dubuntu-build`
build the image locally

### `dubuntu-recreate`
recreate / restart Dubuntu

### `dubuntu-attach`
attatch to running Dubuntu

## Usage
### Boot/Restart VM
### start / stop container
use `docker start dubuntu` and `docker stop dubuntu`

## Recipes
### Change Docker Settings
Any docker related settings are defined in `docker-compose.yaml`. Simply add port mapping / volumes as you wish.

### Connect to Dubuntu via SSH
```bash
# make sure you are in side the Dubuntu directory
# And port 22 is mapped in `docker-compose.yaml`
cat ~/.ssh/id_rsa.pub >> shared/authorized_keys
./start.sh
docker stop dubuntu && docker start dubuntu
ssh root@localhost # or somewhere you defined
```

### Connect to VM
```bash
ssh root@localhost
```
## Configurations
Priority: ENV > Conf files

### Change VM Settings
Put files listed below inside `/shared` to override corresponding settings.
### Config via Environment
- APT_SOURCE=< tuna | official >
- APT_PACKAGES=< additional package list seprated by space >

### Configuration Files
Put files listed below inside `/shared` to override corresponding files inside the container.
- `sources.list`: override `/etc/apt/sources.list` in VM.
- `resolv.conf`: override `/etc/resolv.conf` in VM.
- `authorized_keys`: override `/root/.ssh/authorized_keys` in VM.
Expand All @@ -39,19 +67,9 @@ Put files listed below inside `/shared` to override corresponding settings.
- `ssh_host_rsa_key`: override /etc/ssh/ssh_host_rsa_key, the host rsa key. Will be generated automatically if not exists.
- `zsh_history`: override `/root/.zsh_history` in VM.


## What's Inside
- Ubuntu xenial (16.04)
- basic network utils like telnet, ping, etc.
- lsb
- ssh server
- oh my zsh
- docker engine
- python2 and python3
- ...

## Know Issues
- Because Docker for Mac is running in a real virtual machine([hyperkit](https://github.com/moby/hyperkit)), after a long sleep, the hyperkit may have its clock drift, which may cause the ssh connection fails. Re-run `./start.sh` to workaround.
- Because Docker for Mac is running in a real virtual machine([hyperkit](https://github.com/moby/hyperkit)), after a long sleep, the hyperkit may have its clock drift, which may cause the ssh connection fails. restart the container to workaround.
- `/shared/zsh_history` currently not working

## TODO
- Setup node.js dev environment
Expand Down
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ if [ -n "$APT_SOURCE" ]; then
cp -f "/etc/apt/sources.list.$APT_SOURCE" /etc/apt/sources.list
fi
fi
if [ -n "$APT_PACKAGES" ]; then
apt-get install -y $APT_PACKAGES
fi

# if [ -f /shared/zsh_history ]; then ln -sf /shared/zsh_history /root/.zsh_history; fi
if [ -f /shared/resolv.conf ]; then cat /shared/resolv.conf > /etc/resolv.conf; fi
if [ -f /shared/authorized_keys ]; then
Expand Down
27 changes: 27 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo "#!/usr/bin/env bash
cd \"$DIR\"
docker-compose pull
" > /usr/local/bin/dubuntu-pull
chmod a+x /usr/local/bin/dubuntu-pull

echo "#!/usr/bin/env bash
cd \"$DIR\"
docker-compose build
" > /usr/local/bin/dubuntu-build
chmod a+x /usr/local/bin/dubuntu-build

echo "#!/usr/bin/env bash
cd \"$DIR\"
docker-compose down
docker-compose up -d
" > /usr/local/bin/dubuntu-recreate
chmod a+x /usr/local/bin/dubuntu-recreate

echo "#!/usr/bin/env bash
cd \"$DIR\"
docker-compose exec dubuntu zsh
" > /usr/local/bin/dubuntu-attach
chmod a+x /usr/local/bin/dubuntu-attach
4 changes: 0 additions & 4 deletions start.sh

This file was deleted.

0 comments on commit 66c70b1

Please sign in to comment.