|
1 | 1 | # docker-alias |
2 | 2 |
|
3 | | -Aliases for docker |
4 | | -This will hook into the cd command and look for a docker-alias.yml. |
5 | | -The services in it get extracted and a bash alias is generated. |
| 3 | +Enables you to use docker-containers to execute commands as if they where installed on your system. |
6 | 4 |
|
7 | | -Now you can use "containerized"-tools as if they where installed on your host-machine. |
8 | | - |
9 | | -It also exports some handy environment variables: |
10 | | -* PROJECT_ROOT_PATH - the path where the docker-alias.yml is stored |
11 | | -* LOCAL_UID - the executers uid |
12 | | -* LOCAL_GID - the executers gid |
| 5 | +### Requirements: |
| 6 | +- docker |
| 7 | +- systemd |
| 8 | +- lebokus/bindfs:latest (optional) |
13 | 9 |
|
14 | 10 | ### Installation |
15 | 11 |
|
16 | | -Clone this repo onto your desired destination and source the auto-docker-alias file in your .bashrc or .zshrc: |
17 | | - |
18 | | -``` |
19 | | -source /path/to/repo/auto-docker-alias.sh |
20 | | -PATH=$PATH:/path/to/repo |
21 | | -``` |
| 12 | +`wget -q -O - "https://raw.githubusercontent.com/clecherbauer/docker-alias/2.0.0/online-installer.sh" | bash` |
22 | 13 |
|
23 | 14 | ### Usage |
24 | 15 |
|
25 | | -Create a docker-compose.alias.yml file and define your services: |
26 | | -``` |
27 | | -<<< docker-alias.yml >>> |
28 | | -version: '3' |
29 | | -
|
30 | | -services: |
31 | | - node: |
32 | | - image: node:4 |
33 | | - volumes: |
34 | | - - ${PROJECT_ROOT_DIR}:/app |
35 | | - working_dir: /app |
36 | | - labels: |
37 | | - - com.docker-alias.name=npm |
38 | | -``` |
39 | | - |
40 | | -There are following labels available: |
41 | | - |
42 | | -`com.docker-alias.name=npm` - the alias name and command |
43 | | - |
44 | | -`com.docker-alias.name=[node, npm, vue]` - multiple alias names and commands |
45 | | - |
46 | | -`com.docker-alias.command=/bin/bash` - [Optional] the command wich should be executed in the service, if empty the name will be used as the command |
47 | | - |
48 | | -`com.docker-alias.service=node` - [Optional] the service wich should be used, if not set the service in wich this label appears is used |
| 16 | +1. create a new docker-alias.yml and define your volumes and commands: |
49 | 17 |
|
50 | | -`com.docker-alias.user=www-data` - [Optional] the user wich should be used to execute the service |
51 | | - |
52 | | -`com.docker-alias.keepRoot=true` - [Optional] the command is executed in the services defined workdirectory |
53 | | - |
54 | | -`com.docker-alias.detach=true` - [Optional] start the service detached |
55 | | - |
56 | | -`com.docker-alias.silent=true` - [Optional] silents the services stdout and stderr |
57 | | - |
58 | | -`com.docker-alias.preExecutionCommand` - [Optional] the command is executed on the host before the service starts |
59 | | - |
60 | | - |
61 | | -Now cd into the path with the docker-alias.yml and type docker-alias |
62 | | - |
63 | | -### Tips and Tricks |
64 | | - |
65 | | -Avoid file-permission problems with the [lebokus/bindfs](https://github.com/lebokus/docker-volume-bindfs) docker plugin. |
66 | 18 | ``` |
67 | | -<<< docker-alias.yml >>> |
68 | | -version : '3' |
69 | | -
|
70 | 19 | volumes: |
71 | | - alias_bindfs_mapped_data: |
| 20 | + bindfs: |
72 | 21 | driver: lebokus/bindfs:latest |
73 | | - labels: |
74 | | - - com.docker-alias=true |
75 | 22 | driver_opts: |
76 | | - sourcePath: "${PROJECT_ROOT_PATH}" |
77 | | - map: "${LOCAL_UID}/0:@${LOCAL_UID}/@0" |
| 23 | + sourcePath: "$YAML_LOCATION_DIR" |
| 24 | + map: "$UID/0:@$UID/@0" |
| 25 | +
|
| 26 | +containers: |
| 27 | + python: |
| 28 | + build: |
| 29 | + context: . |
| 30 | + dockerfile: .devops/docker/alias/python/Dockerfile |
| 31 | + volumes: |
| 32 | + - bindfs:$DEFAULT_WORKING_DIR |
| 33 | + - $SSH_AUTH_SOCK:/ssh-auth.sock |
| 34 | + commands: |
| 35 | + - python |
| 36 | + - pip3: |
| 37 | + path: /usr/local/bin/pip3 |
| 38 | + - flake8 |
| 39 | + - autopep8 |
| 40 | + - prospector |
| 41 | + - prospector-html |
| 42 | + env_file: .env |
| 43 | + environment: |
| 44 | + - PYTHONPATH=$DEFAULT_WORKING_DIR |
| 45 | + entrypoint: /usr/local/bin/entrypoint.sh |
78 | 46 |
|
79 | | -services: |
80 | 47 | node: |
81 | | - image: node:4 |
| 48 | + image: node |
82 | 49 | volumes: |
83 | | - - alias_bindfs_mapped_data:/app |
84 | | - working_dir: /app |
85 | | - labels: |
86 | | - - com.docker-alias.name=node |
87 | | -``` |
| 50 | + - bindfs:$DEFAULT_WORKING_DIR |
| 51 | + - $SSH_AUTH_SOCK:/ssh-auth.sock |
| 52 | + commands: |
| 53 | + - node |
| 54 | + - npm |
| 55 | + - npx |
| 56 | + - vue |
| 57 | + env_file: .env |
| 58 | + environment: |
| 59 | + - SSH_AUTH_SOCK=/ssh-auth.sock |
| 60 | +``` |
| 61 | + |
| 62 | +2. register your new docker-alias.yml with `docker-alias add` |
| 63 | + |
| 64 | +3. try out your commands |
| 65 | + |
0 commit comments