-
Notifications
You must be signed in to change notification settings - Fork 0
/
coreos-docker-setup
110 lines (87 loc) · 4.12 KB
/
coreos-docker-setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
These are the steps I took to setup a coreos installation to host various docker containers
1. Create vm with at least 2GB of ram (required?) and boot from coreos iso
2. openssl passwd -1 > cloud-config.yml
3. vim cloud-config.yml and add the following lines
#cloud-config
users:
- name: coreuser
passwd: $1$QJq0Z7rL$GjaetUaSVEU0hM5N3VKpn.
groups:
- sudo
- docker
4. coreos-cloudinit -validate --from-file cloud-config.yml
5. coreos-install -d /dev/sda -C stable -c cloud-config.yml
6. after installation completes remove iso and reboot
--------------------------------------------------------------------------------------------
This is how I setup docker-compose on coreos
1. vim /var/lib/coreos-install/user_data (this is the location of the cloud-config file we created https://coreos.com/os/docs/latest/cloud-config-locations.html)
2. Add the following lines
coreos:
units:
- name: install-docker-compose.service
command: start
content: |
[Unit]
Description=Install docker-compose
ConditionPathExists=!/opt/bin/docker-compose
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/mkdir -p /opt/bin/
ExecStart=/usr/bin/curl -o /opt/bin/docker-compose -sL "https://github.com/docker/compose/releases/download/1.21.2/docker-compose-Linux-x86_64"
ExecStart=/usr/bin/chmod +x /opt/bin/docker-compose
3. coreos-cloudinit -validate --from-file /var/lib/coreos-install/user_data
4. coreos-cloudinit --from-file /var/lib/coreos-install/user_data
--------------------------------------------------------------------------------------------
This is how I setup a cifs mount for shared data storage
1. added following to /var/lib/coreos-install/user_data
units:
- name: basic-mount-cifs.service
enable: true
content: |
[Unit]
Description=Download basic mount.cifs binary
Documentation=https://github.com/xynova/docker-cifs-build
After=network.target
ConditionFileIsExecutable=!/opt/bin/mount.cifs
[Service]
TimeoutStartSec=0
Environment="WORKDIR=/tmp/cifs-mount"
Environment="BINDIR=/opt/bin"
Environment="PKGADDR=quay.io/xynova/cifs-mount"
ExecStartPre=/usr/bin/mkdir -p $BINDIR $WORKDIR
#Download container
ExecStartPre=/bin/curl -o ${WORKDIR}/pkg -L https://xynova+reader:SFZ78VTCO2TNUL6NHTBAWZBU68U1LPCT7EQ26B1ID6MIP3FZOFYRLXSF331WEQT4@quay.io/c1/squash/xynova/cifs-mount/latest
# Manually extract mount.cifs from container into /opt/bin
ExecStartPre=/bin/bash -c "cd $WORKDIR && tar -ztf pkg | grep .tar \
| xargs tar -zxvf pkg $1 \
| xargs tar -xv sbin/mount.cifs -f $1"
ExecStart=/bin/bash -c "cp ${WORKDIR}/sbin/mount.cifs ${BINDIR}/ && rm -Rf $WORKDIR"
[Install]
WantedBy=multi-user.target
RequiredBy=docker.service
- name: mount-cifs-share.service
enable: true
content: |
[Unit]
Description=Mount a cifs share
Requires=basic-mount-cifs.service
After=basic-mount-cifs.service
ConditionPathExists=/opt/bin/mount.cifs
[Service]
Type=oneshot
RemainAfterExit=yes
TimeoutStartSec=0
ExecStartPre=/usr/bin/mkdir -p /srv/datalink
ExecStart=/opt/bin/mount.cifs -o vers=2.1,username=guest,password=,uid=1000,gid=1000 //server.path.com/share/path /srv/datalink/
[Install]
WantedBy=multi-user.target
RequiredBy=docker.service
2. coreos-cloudinit -validate --from-file /var/lib/coreos-install/user_data
3. coreos-cloudinit --from-file /var/lib/coreos-install/user_data
--------------------------------------------------------------------------------------------
Good links
https://stackoverflow.com/questions/29086918/docker-compose-to-coreos
https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files
https://coreos.com/os/docs/latest/getting-started-with-docker.html
https://docs.docker.com/engine/faq