Docker
Docker
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
Without a Dockerfile
If you don't want to include a Dockerfile in your project, it is sufficient to do
the following:
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.
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).
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.
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.
• http://192.168.100.10
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:
/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!!!
******************************************************
It is simply copying data from one server to another server. So all the users can
share the same data without any inconsistency.
High Performance
Backup and Security
Remote Access
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.
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.
Solution 1
To fix the replication error we follow the below steps.
mysql -u root -p
3. For that, we stop the slave from replication, using the below command.
4. Next, we tell the slave to simply skip the invalid SQL query. So we use the
below command.
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
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:
[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.
******************************************************************************
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:
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.
For Raspbian, installing using the repository is not yet supported. You must
instead use the convenience script.
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:
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:
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.
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.
Verify that Docker Engine is installed correctly by running the hello-world image.
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:
You can run the script with the DRY_RUN=1 option to learn what steps the script
will execute during installation:
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: