]> git.proxmox.com Git - mirror_frr.git/blob - doc/developer/building-docker.rst
doc: add Ubuntu18.04 and 20.04 container info to building-docker.rst
[mirror_frr.git] / doc / developer / building-docker.rst
1 Docker
2 ======
3
4 This page covers how to build FRR Docker images.
5
6 Images
7 """"""
8 FRR has Docker build infrastructure to produce Docker images containing
9 source-built FRR on the following base platforms:
10
11 * Alpine
12 * Centos 7
13 * Centos 8
14
15 The following platform images are used to support Travis CI and can also
16 be used to reproduce topotest failures when the docker host is Ubuntu
17 (tested on 18.04 and 20.04):
18
19 * Ubuntu 18.04
20 * Ubuntu 20.04
21
22 The following platform images may also be built, but these simply install a
23 binary package from an existing repository and do not perform source builds:
24
25 * Debian 10
26
27 Some of these are available on `DockerHub
28 <https://hub.docker.com/repository/docker/frrouting/frr/tags?page=1>`_.
29
30 There is no guarantee on what is and is not available from DockerHub at time of
31 writing.
32
33 Scripts
34 """""""
35
36 Some platforms contain an included build script that may be run from the host.
37 This will set appropriate packaging environment variables and clean up
38 intermediate build images.
39
40 These scripts serve another purpose. They allow building platform packages
41 without needing the platform. For example, the Centos 8 docker image can also
42 be leveraged to build Centos 8 RPMs that can then be used separately from
43 Docker.
44
45 If you are only interested in the Docker images and don't want the cleanup
46 functionality of the scripts you can ignore them and perform a normal Docker
47 build. If you want to build multi-arch docker images this is required as the
48 scripts do not support using Buildkit for multi-arch builds.
49
50 Building Alpine Image
51 ---------------------
52
53 Script::
54
55 ./docker/alpine/build.sh
56
57 No script::
58
59 docker build -f docker/alpine/Dockerfile .
60
61 No script, multi-arch (ex. amd64, arm64, armv7)::
62
63 docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -f docker/alpine/Dockerfile -t frr:latest .
64
65
66 Building Debian Image
67 ---------------------
68
69 ::
70
71 cd docker/debian
72 docker build .
73
74 Multi-arch (ex. amd64, arm64, armv7)::
75
76 cd docker/debian
77 docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t frr-debian:latest .
78
79 Building Centos 7 Image
80 -----------------------
81
82 Script::
83
84 ./docker/centos-7/build.sh
85
86 No script::
87
88 docker build -f docker/centos-7/Dockerfile .
89
90 No script, multi-arch (ex. amd64, arm64)::
91
92 docker buildx build --platform linux/amd64,linux/arm64 -f docker/centos-7/Dockerfile -t frr-centos7:latest .
93
94
95 Building Centos 8 Image
96 -----------------------
97
98 Script::
99
100 ./docker/centos-8/build.sh
101
102 No script::
103
104 docker build -f docker/centos-8/Dockerfile .
105
106 No script, multi-arch (ex. amd64, arm64)::
107
108 docker buildx build --platform linux/amd64,linux/arm64 -f docker/centos-8/Dockerfile -t frr-centos8:latest .
109
110
111
112 Building Ubuntu 18.04 Image
113 ---------------------------
114
115 Build image (from project root directory)::
116
117 docker build -t frr-ubuntu18:latest -f docker/ubuntu18-ci/Dockerfile .
118
119 Start the container::
120
121 docker run -d --privileged --name frr-ubuntu18 --mount type=bind,source=/lib/modules,target=/lib/modules frr-ubuntu18:latest
122
123 Running a topotest (when the docker host is Ubuntu)::
124
125 docker exec frr-ubuntu18 bash -c 'cd ~/frr/tests/topotests/ospf-topo1 ; sudo pytest test_ospf_topo1.py'
126
127 Starting an interactive bash session::
128
129 docker exec -it frr-ubuntu18 bash
130
131 Stopping an removing a container::
132
133 docker stop frr-ubuntu18 ; docker rm frr-ubuntu18
134
135 Removing the built image::
136
137 docker rmi frr-ubuntu18:latest
138
139
140 Building Ubuntu 20.04 Image
141 ---------------------------
142
143 Build image (from project root directory)::
144
145 docker build -t frr-ubuntu20:latest -f docker/ubuntu20-ci/Dockerfile .
146
147 Start the container::
148
149 docker run -d --privileged --name frr-ubuntu20 --mount type=bind,source=/lib/modules,target=/lib/modules frr-ubuntu20:latest
150
151 Running a topotest (when the docker host is Ubuntu)::
152
153 docker exec frr-ubuntu20 bash -c 'cd ~/frr/tests/topotests/ospf-topo1 ; sudo pytest test_ospf_topo1.py'
154
155 Starting an interactive bash session::
156
157 docker exec -it frr-ubuntu20 bash
158
159 Stopping an removing a container::
160
161 docker stop frr-ubuntu20 ; docker rm frr-ubuntu20
162
163 Removing the built image::
164
165 docker rmi frr-ubuntu20:latest