Skip to content

Commit 48702c3

Browse files
committed
docs: Use sudo and tee uniformly everywhere
Added sudo uniformly everywhere it required as it presence doesn't affect anything , but it help new user's of linux , docker or kubernetes who are not much familiar with internals and also for who doesn't read the documentation line by line and use the guides for command reference and just copy paste for their use. Also , changed the way of writing or creating files , now using "tee" because previous way gives permission issue for non sudo users.
1 parent 2bc1342 commit 48702c3

File tree

1 file changed

+62
-61
lines changed

1 file changed

+62
-61
lines changed

content/en/docs/setup/production-environment/container-runtimes.md

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ This document is written for users installing CRI onto Linux. For other operatin
3232
systems, look for documentation specific to your platform.
3333
{{< /note >}}
3434

35-
You should execute all the commands in this guide as `root`. For example, prefix commands
36-
with `sudo `, or become `root` and run the commands as that user.
37-
3835
### Cgroup drivers
3936

4037
When systemd is chosen as the init system for a Linux distribution, the init process generates
@@ -76,34 +73,34 @@ Use the following commands to install Docker on your system:
7673
# (Install Docker CE)
7774
## Set up the repository:
7875
### Install packages to allow apt to use a repository over HTTPS
79-
apt-get update && apt-get install -y \
76+
sudo apt-get update && sudo apt-get install -y \
8077
apt-transport-https ca-certificates curl software-properties-common gnupg2
8178
```
8279

8380
```shell
8481
# Add Docker's official GPG key:
85-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
82+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
8683
```
8784

8885
```shell
8986
# Add the Docker apt repository:
90-
add-apt-repository \
87+
sudo add-apt-repository \
9188
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
9289
$(lsb_release -cs) \
9390
stable"
9491
```
9592

9693
```shell
9794
# Install Docker CE
98-
apt-get update && apt-get install -y \
95+
sudo apt-get update && sudo apt-get install -y \
9996
containerd.io=1.2.13-2 \
10097
docker-ce=5:19.03.11~3-0~ubuntu-$(lsb_release -cs) \
10198
docker-ce-cli=5:19.03.11~3-0~ubuntu-$(lsb_release -cs)
10299
```
103100

104101
```shell
105102
# Set up the Docker daemon
106-
cat > /etc/docker/daemon.json <<EOF
103+
cat <<EOF | sudo tee /etc/docker/daemon.json
107104
{
108105
"exec-opts": ["native.cgroupdriver=systemd"],
109106
"log-driver": "json-file",
@@ -116,13 +113,13 @@ EOF
116113
```
117114

118115
```shell
119-
mkdir -p /etc/systemd/system/docker.service.d
116+
sudo mkdir -p /etc/systemd/system/docker.service.d
120117
```
121118

122119
```shell
123120
# Restart Docker
124-
systemctl daemon-reload
125-
systemctl restart docker
121+
sudo systemctl daemon-reload
122+
sudo systemctl restart docker
126123
```
127124
{{% /tab %}}
128125
{{% tab name="CentOS/RHEL 7.4+" %}}
@@ -131,31 +128,31 @@ systemctl restart docker
131128
# (Install Docker CE)
132129
## Set up the repository
133130
### Install required packages
134-
yum install -y yum-utils device-mapper-persistent-data lvm2
131+
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
135132
```
136133

137134
```shell
138135
## Add the Docker repository
139-
yum-config-manager --add-repo \
136+
sudo yum-config-manager --add-repo \
140137
https://download.docker.com/linux/centos/docker-ce.repo
141138
```
142139

143140
```shell
144141
# Install Docker CE
145-
yum update -y && yum install -y \
142+
sudo yum update -y && sudo yum install -y \
146143
containerd.io-1.2.13 \
147144
docker-ce-19.03.11 \
148145
docker-ce-cli-19.03.11
149146
```
150147

151148
```shell
152149
## Create /etc/docker
153-
mkdir /etc/docker
150+
sudo mkdir /etc/docker
154151
```
155152

156153
```shell
157154
# Set up the Docker daemon
158-
cat > /etc/docker/daemon.json <<EOF
155+
cat <<EOF | sudo tee /etc/docker/daemon.json
159156
{
160157
"exec-opts": ["native.cgroupdriver=systemd"],
161158
"log-driver": "json-file",
@@ -171,13 +168,13 @@ EOF
171168
```
172169

173170
```shell
174-
mkdir -p /etc/systemd/system/docker.service.d
171+
sudo mkdir -p /etc/systemd/system/docker.service.d
175172
```
176173

177174
```shell
178175
# Restart Docker
179-
systemctl daemon-reload
180-
systemctl restart docker
176+
sudo systemctl daemon-reload
177+
sudo systemctl restart docker
181178
```
182179
{{% /tab %}}
183180
{{< /tabs >}}
@@ -205,17 +202,17 @@ For more information, see the [CRI-O compatibility matrix](https://github.com/cr
205202
### Prerequisites
206203

207204
```shell
208-
modprobe overlay
209-
modprobe br_netfilter
205+
sudo modprobe overlay
206+
sudo modprobe br_netfilter
210207

211208
# Set up required sysctl params, these persist across reboots.
212-
cat > /etc/sysctl.d/99-kubernetes-cri.conf <<EOF
209+
cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
213210
net.bridge.bridge-nf-call-iptables = 1
214211
net.ipv4.ip_forward = 1
215212
net.bridge.bridge-nf-call-ip6tables = 1
216213
EOF
217214

218-
sysctl --system
215+
sudo sysctl --system
219216
```
220217

221218
{{< tabs name="tab-cri-cri-o-installation" >}}
@@ -237,14 +234,18 @@ To install version 1.18.3, set `VERSION=1.18:1.18.3`.
237234

238235
Then run
239236
```shell
240-
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
241-
echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list
237+
cat <<EOF | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
238+
"deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /"
239+
EOF
240+
cat <<EOF | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list
241+
"deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /"
242+
EOF
242243

243-
curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$VERSION/$OS/Release.key | apt-key add -
244-
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | apt-key add -
244+
curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$VERSION/$OS/Release.key | sudo apt-key add -
245+
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | sudo apt-key add -
245246

246-
apt-get update
247-
apt-get install cri-o cri-o-runc
247+
sudo apt-get update
248+
sudo apt-get install cri-o cri-o-runc
248249
```
249250

250251
{{% /tab %}}
@@ -269,14 +270,14 @@ To install version 1.18.3, set `VERSION=1.18:1.18.3`.
269270

270271
Then run
271272
```shell
272-
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
273-
echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list
273+
sudo echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
274+
sudo echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list
274275

275-
curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$VERSION/$OS/Release.key | apt-key add -
276-
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | apt-key add -
276+
curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$VERSION/$OS/Release.key | sudo apt-key add -
277+
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | sudo apt-key add -
277278

278-
apt-get update
279-
apt-get install cri-o cri-o-runc
279+
sudo apt-get update
280+
sudo apt-get install cri-o cri-o-runc
280281
```
281282
{{% /tab %}}
282283

@@ -299,9 +300,9 @@ To install version 1.18.3, set `VERSION=1.18:1.18.3`.
299300

300301
Then run
301302
```shell
302-
curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/devel:kubic:libcontainers:stable.repo
303-
curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.repo https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$VERSION/$OS/devel:kubic:libcontainers:stable:cri-o:$VERSION.repo
304-
yum install cri-o
303+
sudo curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/devel:kubic:libcontainers:stable.repo
304+
sudo curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.repo https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$VERSION/$OS/devel:kubic:libcontainers:stable:cri-o:$VERSION.repo
305+
sudo yum install cri-o
305306
```
306307

307308
{{% /tab %}}
@@ -318,14 +319,14 @@ Set `$VERSION` to the CRI-O version that matches your Kubernetes version.
318319
For instance, if you want to install CRI-O 1.18, `VERSION=1.18`
319320
You can find available versions with:
320321
```shell
321-
dnf module list cri-o
322+
sudo dnf module list cri-o
322323
```
323324
CRI-O does not support pinning to specific releases on Fedora.
324325

325326
Then run
326327
```shell
327-
dnf module enable cri-o:$VERSION
328-
dnf install cri-o
328+
sudo dnf module enable cri-o:$VERSION
329+
sudo dnf install cri-o
329330
```
330331

331332
{{% /tab %}}
@@ -334,8 +335,8 @@ dnf install cri-o
334335
### Start CRI-O
335336

336337
```shell
337-
systemctl daemon-reload
338-
systemctl start crio
338+
sudo systemctl daemon-reload
339+
sudo systemctl start crio
339340
```
340341

341342
Refer to the [CRI-O installation guide](https://github.com/kubernetes-sigs/cri-o#getting-started)
@@ -350,22 +351,22 @@ Use the following commands to install Containerd on your system:
350351
### Prerequisites
351352

352353
```shell
353-
cat > /etc/modules-load.d/containerd.conf <<EOF
354+
cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
354355
overlay
355356
br_netfilter
356357
EOF
357358

358-
modprobe overlay
359-
modprobe br_netfilter
359+
sudo modprobe overlay
360+
sudo modprobe br_netfilter
360361

361362
# Setup required sysctl params, these persist across reboots.
362-
cat > /etc/sysctl.d/99-kubernetes-cri.conf <<EOF
363+
cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
363364
net.bridge.bridge-nf-call-iptables = 1
364365
net.ipv4.ip_forward = 1
365366
net.bridge.bridge-nf-call-ip6tables = 1
366367
EOF
367368

368-
sysctl --system
369+
sudo sysctl --system
369370
```
370371

371372
### Install containerd
@@ -377,36 +378,36 @@ sysctl --system
377378
# (Install containerd)
378379
## Set up the repository
379380
### Install packages to allow apt to use a repository over HTTPS
380-
apt-get update && apt-get install -y apt-transport-https ca-certificates curl software-properties-common
381+
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
381382
```
382383

383384
```shell
384385
## Add Docker's official GPG key
385-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
386+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
386387
```
387388

388389
```shell
389390
## Add Docker apt repository.
390-
add-apt-repository \
391+
sudo add-apt-repository \
391392
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
392393
$(lsb_release -cs) \
393394
stable"
394395
```
395396

396397
```shell
397398
## Install containerd
398-
apt-get update && apt-get install -y containerd.io
399+
sudo apt-get update && sudo apt-get install -y containerd.io
399400
```
400401

401402
```shell
402403
# Configure containerd
403-
mkdir -p /etc/containerd
404-
containerd config default > /etc/containerd/config.toml
404+
sudo mkdir -p /etc/containerd
405+
sudo containerd config default > /etc/containerd/config.toml
405406
```
406407

407408
```shell
408409
# Restart containerd
409-
systemctl restart containerd
410+
sudo systemctl restart containerd
410411
```
411412
{{% /tab %}}
412413
{{% tab name="CentOS/RHEL 7.4+" %}}
@@ -415,30 +416,30 @@ systemctl restart containerd
415416
# (Install containerd)
416417
## Set up the repository
417418
### Install required packages
418-
yum install -y yum-utils device-mapper-persistent-data lvm2
419+
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
419420
```
420421

421422
```shell
422423
## Add docker repository
423-
yum-config-manager \
424+
sudo yum-config-manager \
424425
--add-repo \
425426
https://download.docker.com/linux/centos/docker-ce.repo
426427
```
427428

428429
```shell
429430
## Install containerd
430-
yum update -y && yum install -y containerd.io
431+
sudo yum update -y && sudo yum install -y containerd.io
431432
```
432433

433434
```shell
434435
## Configure containerd
435-
mkdir -p /etc/containerd
436-
containerd config default > /etc/containerd/config.toml
436+
sudo mkdir -p /etc/containerd
437+
sudo containerd config default > /etc/containerd/config.toml
437438
```
438439

439440
```shell
440441
# Restart containerd
441-
systemctl restart containerd
442+
sudo systemctl restart containerd
442443
```
443444
{{% /tab %}}
444445
{{% tab name="Windows (PowerShell)" %}}

0 commit comments

Comments
 (0)