-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathmacVlan
63 lines (38 loc) · 2.65 KB
/
macVlan
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
# https://docs.docker.com/network/macvlan/
Bridge mode
To create a macvlan network which bridges with a given physical network interface, use --driver macvlan with the docker network create command. You also need to specify the parent, which is the interface the traffic will physically go through on the Docker host.
docker network create -d macvlan \
--subnet=192.168.1.0/24 \
--gateway=192.168.1.1 \
-o parent=ens33 home_asim
docker run --name ubuntu-macvlan --network home_asim -id ubuntu:latest
###
# https://unix.stackexchange.com/questions/490722/unable-to-start-ssh-service-on-centos-docker-image
docker network create -d macvlan --subnet=192.168.1.0/24 --ip-range=192.168.1.100/24 --gateway=192.168.1.1 -o macvlan_mode=bridge -o parent=ens33 home_asim_2
### For Amazon-Linux & Centos-7 ---> SystemD
https://unix.stackexchange.com/questions/490722/unable-to-start-ssh-service-on-centos-docker-image
Systemd is now included in both the centos:7 and centos:latest base containers, but it is not active by default. In order to use systemd, you will need to include text similar to the example Dockerfile below:
The sample Dockerfile provided is as follows:
FROM amazonlinux:latest
ENV container docker
RUN yum update -y && yum install -y net-tools && yum install -y openssh-server openssh-clients
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
By removing these files, systemd is prevented from starting several services during container startup. This approach results in a bare-bones, yet functional systemd inside the container.
Running a container from this image also requires a specific option to mount the cgroup volume:
docker run -it -v /sys/fs/cgroup:/sys/fs/cgroup:ro systemd-app
# For Non-Ubuntu Hosts
docker run --name amazon-linux-macvlan -id -v /sys/fs/cgroup:/sys/fs/cgroup:ro --network home_asim quickbooks2018/amazonlinux
# Docker inside docker
docker run --name amazonlinux -id --user=root -v $(which docker):/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock amazonlinux:latest
# For Ubuntu Hosts
docker run --name amazon-linux-macvlan -id -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /tmp/$(mktemp -d):/run --network home_asim quickbooks2018/amazonlinux