0% found this document useful (0 votes)
61 views15 pages

Docker

The document discusses the configuration of the Apache HTTP server on Ubuntu Linux using Docker. It provides commands to install Docker, pull the Apache HTTP image, run a new Apache container exposing port 80, and create a volume for persistent Apache data. The server configurations are stored in various directories under /etc/apache2 on the host system, and the Apache container uses the httpd image to run a simple HTML server by mapping files from the host directory into the container.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views15 pages

Docker

The document discusses the configuration of the Apache HTTP server on Ubuntu Linux using Docker. It provides commands to install Docker, pull the Apache HTTP image, run a new Apache container exposing port 80, and create a volume for persistent Apache data. The server configurations are stored in various directories under /etc/apache2 on the host system, and the Apache container uses the httpd image to run a simple HTML server by mapping files from the host directory into the container.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 15

**********************CONFIGURACIÓN APACHE*****************

SERVER CONFIGURATIONS
/etc/apache2/apache2.conf
/etc/apache2/ports.conf
/etc/apache2/sites-available
/etc/apache2/sites-enabled
/etc/apache2/conf-available , /etc/apache2/conf-enabled
/etc/apache2/mods-available, /etc/apache2/mods-enabled

***********************************************************

What is httpd?
The Apache HTTP Server, colloquially called Apache, is a Web server application
notable for playing a key role in the initial growth of the World Wide Web.
Originally based on the NCSA HTTPd server, development of Apache began in early
1995 after work on the NCSA code stalled. Apache quickly overtook NCSA HTTPd as the
dominant HTTP server, and has remained the most popular HTTP server in use since
April 1996.

wikipedia.org/wiki/Apache_HTTP_Server

logo

How to use this image.


This image only contains Apache httpd with the defaults from upstream. There is no
PHP installed, but it should not be hard to extend. On the other hand, if you just
want PHP with Apache httpd see the PHP image and look at the -apache tags. If you
want to run a simple HTML server, add a simple Dockerfile to your project where
public-html/ is the directory containing all your HTML.

Create a Dockerfile in your project


FROM httpd:2.4
COPY ./public-html/ /usr/local/apache2/htdocs/
Then, run the commands to build and run the Docker image:

$ docker build -t my-apache2 .


$ docker run -dit --name my-running-app -p 8080:80 my-apache2
Visit http://localhost:8080 and you will see It works!

Without a Dockerfile
If you don't want to include a Dockerfile in your project, it is sufficient to do
the following:

$ docker run -dit --name my-apache-app -p 8080:80 -v


"$PWD":/usr/local/apache2/htdocs/ httpd:2.4
Configuration
To customize the configuration of the httpd server, first obtain the upstream
default configuration from the container:

$ docker run --rm httpd:2.4 cat /usr/local/apache2/conf/httpd.conf > my-httpd.conf


You can then COPY your custom configuration in as
/usr/local/apache2/conf/httpd.conf:

FROM httpd:2.4
COPY ./my-httpd.conf /usr/local/apache2/conf/httpd.conf
SSL/HTTPS
If you want to run your web traffic over SSL, the simplest setup is to COPY or
mount (-v) your server.crt and server.key into /usr/local/apache2/conf/ and then
customize the /usr/local/apache2/conf/httpd.conf by removing the comment symbol
from the following lines:

...
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
...
#LoadModule ssl_module modules/mod_ssl.so
...
#Include conf/extra/httpd-ssl.conf
...
The conf/extra/httpd-ssl.conf configuration file will use the certificate files
previously added and tell the daemon to also listen on port 443. Be sure to also
add something like -p 443:443 to your docker run to forward the https port.

This could be accomplished with a sed line similar to the following:

RUN sed -i \
-e 's/^#\(Include .*httpd-ssl.conf\)/\1/' \
-e 's/^#\(LoadModule .*mod_ssl.so\)/\1/' \
-e 's/^#\(LoadModule .*mod_socache_shmcb.so\)/\1/' \
conf/httpd.conf
The previous steps should work well for development, but we recommend customizing
your conf files for production, see httpd.apache.org for more information about SSL
setup.

Image Variants
The httpd images come in many flavors, each designed for a specific use case.

httpd:<version>
This is the defacto image. If you are unsure about what your needs are, you
probably want to use this one. It is designed to be used both as a throw away
container (mount your source code and start the container to start your app), as
well as the base to build other images off of.

Some of these tags may have names like bullseye in them. These are the suite code
names for releases of Debian and indicate which release the image is based on. If
your image needs to install any additional packages beyond what comes with the
image, you'll likely want to specify one of these explicitly to minimize breakage
when there are new releases of Debian.

httpd:<version>-alpine
This image is based on the popular Alpine Linux project, available in the alpine
official image. Alpine Linux is much smaller than most distribution base images
(~5MB), and thus leads to much slimmer images in general.

This variant is useful when final image size being as small as possible is your
primary concern. The main caveat to note is that it does use musl libc instead of
glibc and friends, so software will often run into issues depending on the depth of
their libc requirements/assumptions. See this Hacker News comment thread for more
discussion of the issues that might arise and some pro/con comparisons of using
Alpine-based images.

To minimize image size, it's uncommon for additional related tools (such as git or
bash) to be included in Alpine-based images. Using this image as a base, add the
things you need in your own Dockerfile (see the alpine image description for
examples of how to install packages if you are unfamiliar).

License
View license information for the software contained in this image.
As with all Docker images, these likely also contain other software which may be
under other licenses (such as Bash, etc from the base distribution, along with any
direct or indirect dependencies of the primary software being contained).

Some additional license information which was able to be auto-detected might be


found in the repo-info repository's httpd/ directory.

As for any pre-built image usage, it is the image user's responsibility to ensure
that any use of this image complies with any relevant licenses for all software
contained within.

***********************************************************************************
***************

1 ssh 172.16.182.138
2 ssh 172.16.182.138 contactar
3 ssh contactar@172.16.182.138
4 ping 200.21.200.10
5 ping 200.21.200.10
6 root@172.16.18.118
7 ssh root@172.16.18.118
8 ls
9 ssh root@172.16.18.118
10 ssh monitor@172.16.18.118
11 ssh monitoreo@172.16.18.118
12 ping 200.21.200.10
13 exit
14 ssh monitoreo@172.16.18.118
15 exit
16 xcode-select --install
17 xcode-select --install
18 /bin/bash -c "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
19 ping 8.8.8.8
20 ssh monitoreo@172.16.18.118
21 docker run -d -p 80:80 docker/getting-started
22 ip add
23 ip add
24 ipadd
25 ifconfig
26 ping 172.17.0.2
27 exit
28 docker exec -it
7cc222bf1ff8d2c6f86b7e72f6e3ab1ae26ad88aad0ddfb31db152b941397fbe /bin/sh
29 exit
30 docker exec -it
7cc222bf1ff8d2c6f86b7e72f6e3ab1ae26ad88aad0ddfb31db152b941397fbe /bin/sh
31 ssh ip172-18-0-36-c8qgsbvnjsv000alrdd0@direct.labs.play-with-docker.com
32 ssh ip172-18-0-36-c8qgsbvnjsv000alrdd0@direct.labs.play-with-docker.com
33 docker
34 docker ps -a
35 docker ps -a
36 docker ps -a
37 ip add
38 ip -add
39 ip a
40 ip -a
41 ifconfig
42 ping 192.168.0.8
43 docker ps -a
44 docker ps -a
45 ps -a
46 docker ps -all
47 ps -all
48 docker run mysql --name mysql
49 docker run mysql --name mysql
50 docker ps -a
51 docker start mysql
52 docker start amazing_hopper
53 docker ps -all
54 docker ps
55 docker ps -a
56 docker run ubuntu
57 docker ps -a
58 docker -it ubuntu
59 docker run -it ubuntu
60 docker rm ubuntu
61 docker rm ubuntu
62 docker ps -a
63 ping 200.21.200
64 ls
65 docker -a
66 docker ps -a
67 docker ps -a
68 docker -it ubuntu
69 docker ps -a
70 docker run ubuntu
71 docker -it ubuntu
72 docker run -it ubuntu
73 docker pull httpd
74 pwd
75 ls
76 cd \\\\#¢
77 docker image ls
78 docker run httpd
79 docker build -t my-apache2
80 docker run -dit --name httpd -p 8080:80 my-apache2
81 docker -ps
82 docker ps -a
83 docker --name dreamy_snyder httpd
84 docker ps -a
85 docker rename dreamy_snyder httpd
86 docker rm adoring_shtern
87 docker rm lucid_northcutt
88 docker rm heuristic_kare
89 docker rm amazing_hopper
90 docker rm flamboyant_keldysh
91 docker rm keen_turing
92 docker ps -all
93 docker ps -a
94 docker rename angry_bhaskara ubuntu
95 history

***********************************************************************************
******
Tutorial Apache - Instalación de Docker en Ubuntu Linux
Instale el servicio Docker.

Copy to Clipboard
apt-get update
apt-get install docker.io
Descargue la imagen de docker de Apache desde el repositorio en línea.

Copy to Clipboard
docker pull httpd
Enumere las imágenes de Docker instaladas en el sistema.

Copy to Clipboard
docker images
Aquí está la salida del comando:

Copy to Clipboard
REPOSITORY TAG IMAGE ID CREATED
SIZE
httpd latest 417af7dc28bc 2 days ago
138MB
Inicie un nuevo contenedor Apache con esta imagen de Docker.

Copy to Clipboard
docker run -d --name apache-server -p 80:80 httpd
Aquí está la salida del comando:

Copy to Clipboard
605238b70aad46ac80ef7a9013e5dbf376dbaad487130553c0a0db85c3847532
En nuestro ejemplo, la imagen de Docker se usó para iniciar un nuevo contenedor.

El nuevo contenedor utiliza el puerto local 80.

El identificador del contenedor es


605238b70aad46ac80ef7a9013e5dbf376dbaad487130553c0a0db85c3847532

¡Felicitaciones! Ha terminado la instalación de Apache Docker en Ubuntu Linux.

Docker Apache - Datos persistentes


Cree un volumen acoplable para los datos persistentes.

Copy to Clipboard
docker volume create apache-data
Compruebe el directorio de datos persistente.

Copy to Clipboard
docker volume inspect apache-data
Aquí está la salida del comando:

Copy to Clipboard
[
{
"CreatedAt": "2020-09-18T19:48:28Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/apache-data/_data",
"Name": "apache-data",
"Options": {},
"Scope": "local"
}
]
Opcionalmente, cree un vínculo simbólico a una ubicación de acceso más fácil.

Copy to Clipboard
ln -s /var/lib/docker/volumes/apache-data/_data /apache
Inicie un contenedor Apache con almacenamiento de datos persistente.

Copy to Clipboard
docker run -d --name apache-server -p 80:80 -v
apache-data:/usr/local/apache2/htdocs httpd
Compruebe el contenido del directorio de datos persistente.

Copy to Clipboard
ls /var/lib/docker/volumes/apache-data/_data
Aquí está la salida del comando:

Copy to Clipboard
index.html
¡Felicitaciones! Ha configurado correctamente el uso del almacenamiento de datos
persistente de Docker.

Tutorial Apache - Prueba de la instalación de Docker


Abra su navegador e introduzca la dirección IP de su servidor web.

En nuestro ejemplo, se introdujo la siguiente URL en el navegador:

• http://192.168.100.10

El servidor Apache mostrará el sitio web predeterminado.

Apache default page


¡Felicitaciones! La instalación de Apache Docker se ha probado correctamente.

Tutorial Apache - Administración de contenedores de Docker


Compruebe el estado de todos los contenedores de Docker mediante el siguiente
comando:

Copy to Clipboard
docker ps -a
Aquí está la salida del comando:

Copy to Clipboard
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
605238b70aad httpd "httpd-foreground" 56 seconds ago
Up 54 seconds 0.0.0.0:80->80/tcp apache-server
Compruebe el estado del contenedor Apache utilizando el ID o su nombre.

Copy to Clipboard
docker ps -a -f id=605238b70aad46ac80ef7a9013e5dbf376dbaad487130553c0a0db85c3847532
docker ps -a -f name=apache-server
Aquí está la salida del comando:

Copy to Clipboard
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
605238b70aad httpd "httpd-foreground" 56 seconds ago
Up 54 seconds 0.0.0.0:80->80/tcp apache-server
Para detener el servicio de contenedor Apache, utilice el siguiente comando:

Copy to Clipboard
docker container stop
605238b70aad46ac80ef7a9013e5dbf376dbaad487130553c0a0db85c3847532
docker container stop apache-server
Para iniciar el servicio de contenedor Apache, utilice el siguiente comando:

Copy to Clipboard
docker container start
605238b70aad46ac80ef7a9013e5dbf376dbaad487130553c0a0db85c3847532
docker container start apache-server
Para reiniciar el servicio de contenedor Apache, utilice el siguiente comando:

Copy to Clipboard
docker container restart
605238b70aad46ac80ef7a9013e5dbf376dbaad487130553c0a0db85c3847532
docker container restart apache-server
En caso de error, utilice el siguiente comando para verificar los registros del
contenedor Apache.

Copy to Clipboard
docker logs 605238b70aad46ac80ef7a9013e5dbf376dbaad487130553c0a0db85c3847532
docker logs apache-server
En nuestros ejemplos, mostramos cómo administrar el contenedor Apache utilizando su
ID o el nombre previamente definido.
***********************************************************************************
***

**************************USO DE VOLUMENES
PERSISTENTES**************************************
Uso de volúmenes persistentesPermalink
La información que se guarda en un contenedor no es persistente.
Los contenedores que implementan aplicaciones Stateful deben guardar los datos en
un medio de almacenamiento persistente. Desacoplamos la aplicación de los datos.
Con docker podemos gestionar volúmenes de datos, que nos permiten guardar la
información en el host (almacenamiento persistente).
Ventajas de guardar los datos en almacenamiento persistentePermalink
Los contenedores son más livianos.
Puedo tener datos distintos en los distintos entornos de desarrollo.
Si un contenedor falla, no se pierde información sólo tengo que crear un nuevo
contenedor.
La modificación de los datos de la aplicación no conlleva la construcción de una
nueva imagen.
Ejemplo de almacenamiento persistentePermalink
Vamos a crear un contenedor con mysql donde guardamos la información de la base de
datos en un volumen persistente:

$ docker run --name some-mysql -v /opt/mysql:/var/lib/mysql -e


MYSQL_ROOT_PASSWORD=asdasd -d mysql
Comprobamos que se ha guardado la base de datos en el host:

/opt/mysql$ ls
ibdata1 ib_logfile0 ib_logfile1 ibtmp1 #innodb_temp mysql mysql.ibd undo_001
undo_002
Creamos una base de datos:
$ docker exec -it some-mysql bash
root@75544a024f9b:/# mysql -u root -p -h localhost
...
create database dbtest;
Query OK, 1 row affected (0.07 sec)
Qué pasa si nuestro nuestro contenedor falla!!!

$ docker container rm -f some-mysql


Podemos crear otro contenedor y comprobar como sigue existiendo la base de datos:

$ docker run --name some-mysql2 -v /opt/mysql:/var/lib/mysql -e


MYSQL_ROOT_PASSWORD=asdasd -d mysql

$ docker exec -it some-mysql2 bash


root@878f77d80fcf:/# mysql -u root -p -h localhost
...
show databases;
...
| dbtest |
...
***********************************************************************************
**************

sudo systemctl start docker

******************************************************

What is MYSQL replication?


Normally, it is a process that enables data from one MySQL database server (the
master) to copied automatically to one or more MySQL database servers (the slaves).
However, general principles of setting up the MySQL master-slave replication on the
same machine are the same for all operating systems.

It is simply copying data from one server to another server. So all the users can
share the same data without any inconsistency.

The main Advantages of MySQL Replication includes,

High Performance
Backup and Security
Remote Access

Reasons for MYSQL replication error 1146.


This is a generic error when we discover the slave MySQL server is having a problem
replicating data from the master. The main reason for this error is due to invalid
MySQL queries or non-existing mysql queries.

Recently one of our customers contacted us with this MYSQL error when he tried to
set-up the MYSQL replication. Then he checked the slave status and returned the
error code like this.

MYSQL replication error 1146

The above error message shows that the table “db3.table3” does not exist in the
slave database. To fix this error, we just simply ignore this error and resume the
replication.

How we fix the MYSQL replication error 1146.


So far, we discuss the MYSQL replication and reasons for the replication error
1146. Now let’s see how our Support Engineers fix this error for our customers.

Solution 1
To fix the replication error we follow the below steps.

1. First, we log into the MYSQL.

mysql -u root -p

2. On the MySQL shell, we check the slave status.

mysql> SHOW SLAVE STATUS


The sample result as follows.

mysql> SHOW SLAVE STATUS


*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 1.2.3.4
Master_User: slave_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.001089
Read_Master_Log_Pos: 269214467
Relay_Log_File: slave-relay.000234
Relay_Log_Pos: 100125935
Relay_Master_Log_File: mysql-bin.001079
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB: mydb
Last_Errno: 1146

If anyone of the Slave_IO_Running or Slave_SQL_Running is set as NO, it means the


replication is broken.

So, we start to repair the MYSQL replication.

3. For that, we stop the slave from replication, using the below command.

mysql> STOP SLAVE;

4. Next, we tell the slave to simply skip the invalid SQL query. So we use the
below command.

mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;


This query tells the slave to skip one query (which is the invalid one that caused
the replication to stop). If we like to skip two queries, we use the following
code instead.
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 2;
That’s it.

5. Again, we start the slave.

mysql> START SLAVE;


6. After that, we check if replication is working again.

mysql> SHOW SLAVE STATUS

mysql> SHOW SLAVE STATUS


*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 1.2.3.4
Master_User: slave_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.001089
Read_Master_Log_Pos: 269214467
Relay_Log_File: slave-relay.000234
Relay_Log_Pos: 100125935
Relay_Master_Log_File: mysql-bin.001079
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: mydb
Last_Errno: 1146
Both Slave_IO_Running and Slave_SQL_Running are set to Yes now. And the replication
is running without any error.

Then we leave the MySQL shell.

mysql> quit;

Solution 2
Recently another customer contacted us with the MYSQL replication error. He also
tried to set up the MYSQL replication and returns the error as follows.

[ERROR] Slave I/O: Unable to load replication GTID slave state from
mysql.gtid_slave_pos: Table 'mysql.gtid_slave_pos' doesn't exist, Internal MariaDB
error code: 1146

Next, he tried mysql_upgrade` and it looked already up to date, so he tried –force,


which gave:

mysql.gtid_slave_pos
Error : Table 'mysql.gtid_slave_pos' doesn't exist in engine
status: Operation failed
Then he checked the dB/mysql folder and found that the .frm and .ibd is already
existing.

gtid_slave_pos.frm
gtid_slave_pos.ibd

Then we just removed the files and recreated the table, which solved the error.

1. So we go to the mysql folder and drop the following files using the command.
rm gtid_slave_pos.frm
rm gtid_slave_pos.ibd
Also, to create the table we use the command:

CREATE TABLE table_name (column_name column_type);


2. Then, we stop and start the slave

mysql]> stop slave;

mysql]> start slave;


This fixes the error.

[Need more assistance for MYSQL replication error 1146? We’ll help you]

Conclusion
In short, the main reasons for the MYSQL replication error 1146 is invalid MySQL
queries or non-existing SQL queries. Today, we saw how our Support Engineers fix
this error for our customers.

******************************************************************************

***************************************INSTALL DOCKER IN DEBIAN


***********************
Install Docker Engine on Debian
Estimated reading time: 11 minutes

To get started with Docker Engine on Debian, make sure you meet the prerequisites,
then install Docker.

Prerequisites
OS requirements
To install Docker Engine, you need the 64-bit version of one of these Debian or
Raspbian versions:

Debian Bullseye 11 (stable)


Debian Buster 10 (oldstable)
Raspbian Bullseye 11 (stable)
Raspbian Buster 10 (oldstable)
Docker Engine is supported on x86_64 (or amd64), armhf, and arm64 architectures.

Uninstall old versions


Older versions of Docker were called docker, docker.io, or docker-engine. If these
are installed, uninstall them:

sudo apt-get remove docker docker-engine docker.io containerd runc


It’s OK if apt-get reports that none of these packages are installed.

The contents of /var/lib/docker/, including images, containers, volumes, and


networks, are preserved. The Docker Engine package is now called docker-ce.

Installation methods
You can install Docker Engine in different ways, depending on your needs:
Most users set up Docker’s repositories and install from them, for ease of
installation and upgrade tasks. This is the recommended approach, except for
Raspbian.

Some users download the DEB package and install it manually and manage upgrades
completely manually. This is useful in situations such as installing Docker on air-
gapped systems with no access to the internet.

In testing and development environments, some users choose to use automated


convenience scripts to install Docker. This is currently the only approach for
Raspbian.

Install using the repository


Before you install Docker Engine for the first time on a new host machine, you need
to set up the Docker repository. Afterward, you can install and update Docker from
the repository.

Raspbian users cannot use this method!

For Raspbian, installing using the repository is not yet supported. You must
instead use the convenience script.

Set up the repository


Update the apt package index and install packages to allow apt to use a repository
over HTTPS:

sudo apt-get update


sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o


/usr/share/keyrings/docker-archive-keyring.gpg
Use the following command to set up the stable repository. To add the nightly or
test repository, add the word nightly or test (or both) after the word stable in
the commands below. Learn about nightly and test channels.

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-
archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >
/dev/null
Install Docker Engine
This procedure works for Debian on x86_64 / amd64, armhf, arm64, and Raspbian.

Update the apt package index, and install the latest version of Docker Engine and
containerd, or go to the next step to install a specific version:

sudo apt-get update


sudo apt-get install docker-ce docker-ce-cli containerd.io
Got multiple Docker repositories?

If you have multiple Docker repositories enabled, installing or updating without


specifying a version in the apt-get install or apt-get update command always
installs the highest possible version, which may not be appropriate for your
stability needs.

Receiving a GPG error when running apt-get update?

Your default umask may not be set correctly, causing the public key file for the
repo to not be detected. Run the following command and then try to update your repo
again: sudo chmod a+r /usr/share/keyrings/docker-archive-keyring.gpg.

To install a specific version of Docker Engine, list the available versions in the
repo, then select and install:

a. List the versions available in your repo:

apt-cache madison docker-ce


b. Install a specific version using the version string from the second column, for
example, 5:18.09.1~3-0~debian-stretch .

sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING>


containerd.io
Verify that Docker Engine is installed correctly by running the hello-world image.

sudo docker run hello-world


This command downloads a test image and runs it in a container. When the container
runs, it prints a message and exits.

Docker Engine is installed and running. The docker group is created but no users
are added to it. You need to use sudo to run Docker commands. Continue to Linux
postinstall to allow non-privileged users to run Docker commands and for other
optional configuration steps.

Upgrade Docker Engine


To upgrade Docker Engine, first run sudo apt-get update, then follow the
installation instructions, choosing the new version you want to install.

Install from a package


If you cannot use Docker’s repository to install Docker Engine, you can download
the .deb file for your release and install it manually. You need to download a new
file each time you want to upgrade Docker.

Go to https://download.docker.com/linux/debian/dists/, choose your Debian version,


then browse to pool/stable/, choose amd64, armhf, or arm64, and download the .deb
file for the Docker Engine version you want to install.

Note

To install a nightly or test (pre-release) package, change the word stable in the
above URL to nightly or test. Learn about nightly and test channels.

Install Docker Engine, changing the path below to the path where you downloaded the
Docker package.

sudo dpkg -i /path/to/package.deb


The Docker daemon starts automatically.

Verify that Docker Engine is installed correctly by running the hello-world image.

sudo docker run hello-world


This command downloads a test image and runs it in a container. When the container
runs, it prints a message and exits.
Docker Engine is installed and running. The docker group is created but no users
are added to it. You need to use sudo to run Docker commands. Continue to Post-
installation steps for Linux to allow non-privileged users to run Docker commands
and for other optional configuration steps.

Upgrade Docker Engine


To upgrade Docker Engine, download the newer package file and repeat the
installation procedure, pointing to the new file.

Install using the convenience script


Docker provides a convenience script at get.docker.com to install Docker into
development environments quickly and non-interactively. The convenience script is
not recommended for production environments, but can be used as an example to
create a provisioning script that is tailored to your needs. Also refer to the
install using the repository steps to learn about installation steps to install
using the package repository. The source code for the script is open source, and
can be found in the docker-install repository on GitHub.

Always examine scripts downloaded from the internet before running them locally.
Before installing, make yourself familiar with potential risks and limitations of
the convenience script:

The script requires root or sudo privileges to run.


The script attempts to detect your Linux distribution and version and configure
your package management system for you, and does not allow you to customize most
installation parameters.
The script installs dependencies and recommendations without asking for
confirmation. This may install a large number of packages, depending on the current
configuration of your host machine.
By default, the script installs the latest stable release of Docker, containerd,
and runc. When using this script to provision a machine, this may result in
unexpected major version upgrades of Docker. Always test (major) upgrades in a test
environment before deploying to your production systems.
The script is not designed to upgrade an existing Docker installation. When using
the script to update an existing installation, dependencies may not be updated to
the expected version, causing outdated versions to be used.
Tip: preview script steps before running

You can run the script with the DRY_RUN=1 option to learn what steps the script
will execute during installation:

curl -fsSL https://get.docker.com -o get-docker.sh


DRY_RUN=1 sh ./get-docker.sh
This example downloads the script from get.docker.com and runs it to install the
latest stable release of Docker on Linux:

curl -fsSL https://get.docker.com -o get-docker.sh


sudo sh get-docker.sh
Docker is installed. The docker service starts automatically on Debian based
distributions. On RPM based distributions, such as CentOS, Fedora, RHEL or SLES,
you need to start it manually using the appropriate systemctl or service command.
As the message indicates, non-root users cannot run Docker commands by default.

Use Docker as a non-privileged user, or install in rootless mode?

The installation script requires root or sudo privileges to install and use Docker.
If you want to grant non-root users access to Docker, refer to the post-
installation steps for Linux. Docker can also be installed without root privileges,
or configured to run in rootless mode. For instructions on running Docker in
rootless mode, refer to run the Docker daemon as a non-root user (rootless mode).

Install pre-releases
Docker also provides a convenience script at test.docker.com to install pre-
releases of Docker on Linux. This script is equivalent to the script at
get.docker.com, but configures your package manager to enable the “test” channel
from our package repository, which includes both stable and pre-releases (beta
versions, release-candidates) of Docker. Use this script to get early access to new
releases, and to evaluate them in a testing environment before they are released as
stable.

To install the latest version of Docker on Linux from the “test” channel, run:

curl -fsSL https://test.docker.com -o test-docker.sh


sudo sh test-docker.sh
Upgrade Docker after using the convenience script
If you installed Docker using the convenience script, you should upgrade Docker
using your package manager directly. There is no advantage to re-running the
convenience script, and it can cause issues if it attempts to re-add repositories
which have already been added to the host machine.

Uninstall Docker Engine


Uninstall the Docker Engine, CLI, and Containerd packages:

sudo apt-get purge docker-ce docker-ce-cli containerd.io


Images, containers, volumes, or customized configuration files on your host are not
automatically removed. To delete all images, containers, and volumes:

sudo rm -rf /var/lib/docker


sudo rm -rf /var/lib/containerd
You must delete any edited configuration files manually.
********************************************************************************

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy