You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
1.9 KiB
107 lines
1.9 KiB
# DOCKER
|
|
|
|
Une simple Dockerfile contenant un NGINX 1.19 pouvant accueillir un site web.
|
|
|
|
## PROCESSUS
|
|
|
|
### INSTALLATION DE DOCKER (DEBIAN 10):
|
|
|
|
```bash
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install \
|
|
apt-transport-https \
|
|
ca-certificates \
|
|
curl \
|
|
gnupg \
|
|
lsb-release
|
|
|
|
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
|
|
echo \
|
|
"deb [arch=amd64 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
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
|
|
```
|
|
|
|
### CREER UN COMPTE SUR DOCKER HUB:
|
|
|
|
https://hub.docker.com
|
|
|
|
* clonage du repo Docker:
|
|
|
|
```bash
|
|
sudo git clone https://github.com/GregLebreton/docker.git
|
|
```
|
|
|
|
### CONSTRUCTION DE L'IMAGE:
|
|
|
|
```bash
|
|
docker build .
|
|
```
|
|
|
|
### TAG DE L'IMAGE:
|
|
|
|
```bash
|
|
docker tag <ID_de_l'image> <nom_de_votre_registre>/<nom_de_l'image>:<tag>
|
|
```
|
|
|
|
* ou on peux tagger l'image lors du docker run:
|
|
|
|
```bash
|
|
docker run -d -p 80:80 -t <nom_de_l_image_docker>:<tag_de_l_image>
|
|
```
|
|
|
|
### DEMARRER UN CONTENAIRE DE L'IMAGE EN Y MAPPANT LE PORT 80 DE LA MACHINE HÔTE:
|
|
|
|
```bash
|
|
docker run -d -p 7000:80 <nom_de_votre_registre>/<nom_de_l'image>:<tag>
|
|
```
|
|
|
|
### VISITER SON NAVIGATEUR A L'ADRESSE:
|
|
|
|
http://localhost:7000
|
|
|
|
### TIPS:
|
|
|
|
* Docker sans sudo:
|
|
|
|
```bash
|
|
sudo groupadd -f docker
|
|
sudo chown root:docker /var/run/docker.sock
|
|
sudo usermod -a -G docker "$(whoami)"
|
|
newgrp docker
|
|
sudo systemctl restart docker
|
|
```
|
|
|
|
* Autres commandes utiles:
|
|
|
|
- push un conteneur sur son registre DockerHub:
|
|
|
|
```bash
|
|
docker push
|
|
```
|
|
- afficher les images docker:
|
|
```bash
|
|
docker ps
|
|
```
|
|
- afficher les containers docker:
|
|
```bash
|
|
docker ls
|
|
```
|
|
- Effacer une image:
|
|
```bash
|
|
docker rmi
|
|
```
|
|
- Effacer un conteneur:
|
|
```bash
|
|
docker rm
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|