Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
wiki2:docker-examples [2019/02/09 11:14] alfred [Eliminar todas las imagenes y contenedores] |
wiki2:docker-examples [2022/10/19 16:37] (actual) |
||
|---|---|---|---|
| Línea 115: | Línea 115: | ||
| gateway: 10.5.0.1 | gateway: 10.5.0.1 | ||
| </code> | </code> | ||
| + | |||
| + | |||
| + | You can set the property ''container_name'' to the service. In this way you will be able to address that container without requiring ''docker-compose'' command. | ||
| ===== Linux Alpine use ===== | ===== Linux Alpine use ===== | ||
| Línea 170: | Línea 173: | ||
| </code> | </code> | ||
| + | ==== Keep a container running ==== | ||
| + | However, if you really need (or want) to run multiple service in your Docker container, consider starting from "[[https://phusion.github.io/baseimage-docker/|Docker Base Image]]", which uses runit as a pseudo-init process (runit will stay online while Nginx and Supervisor run), which will stay in the foreground while your other processes do their thing. | ||
| + | |||
| + | If you are using a Dockerfile, try: ''ENTRYPOINT ["tail", "-f", "/dev/null"]''. You can also run plain ''cat'' without any arguments. | ||
| + | |||
| + | If you are running your container with the -t and -d flag, it keeps running. ''docker run -td <image>''. The most important one is the -t flag. -d just lets you run the container in the background. Here is what the flags do (according to docker run --help): | ||
| + | <code> | ||
| + | -d, --detach=false Run container in background and print container ID | ||
| + | -t, --tty=false Allocate a pseudo-TTY | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ==== Mantener un contenedor abierto sin ningún comando ==== | ||
| + | Dockerfile de ejemplo: | ||
| + | <code> | ||
| + | FROM ubuntu:16.04 | ||
| + | # other commands | ||
| + | CMD tail -f /dev/null | ||
| + | </code> | ||
| + | |||
| + | ==== Problema en docker-compose ==== | ||
| + | Al hacer un ''docker-compose up'' puede aparecer el siguiente error: | ||
| + | <code> | ||
| + | docker-compose: error while loading shared libraries: libz.so.1: failed to map segment from shared object | ||
| + | </code> | ||
| + | Es fácilmente solucionable ejecutando: | ||
| + | <code> | ||
| + | mount /tmp -o remount,exec | ||
| + | </code> | ||
| + | |||
| + | ==== Fully reset the docker system ==== | ||
| + | |||
| + | :!: This remove everything, even volumes. | ||
| + | |||
| + | <code> | ||
| + | service stop docker | ||
| + | rm -Rf /var/lib/docker | ||
| + | service start docker | ||
| + | </code> | ||
| + | |||
| + | ==== Change the docker folder ==== | ||
| + | |||
| + | Remember to do ''service docker stop'' and ''service docker start''. | ||
| + | |||
| + | Edit or create the file ''/etc/docker/daemon.json'': | ||
| + | <code> | ||
| + | { | ||
| + | "data-root": "/home/docker" | ||
| + | } | ||
| + | </code> | ||
| + | Default: "/var/lib/docker" | ||
| ===== Related software ===== | ===== Related software ===== | ||
| Línea 180: | Línea 234: | ||
| </code> | </code> | ||
| + | ===== Problemas con los certificados ===== | ||
| + | |||
| + | **Problema: x509: certificate signed by unknown authority** | ||
| + | |||
| + | https://stackoverflow.com/questions/50768317/docker-pull-certificate-signed-by-unknown-authority/55260438#55260438 | ||
| + | |||
| + | Import the cert to system, saving the cert to the file: | ||
| + | <code> | ||
| + | openssl s_client -showcerts -connect [registry_address]:[registry_port] < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ca.crt | ||
| + | </code> | ||
| + | If the registry root is ''arquitectura-public-registry.ajuntament.bcn'' then the address is: ''arquitectura-public-registry.ajuntament.bcn:443''. | ||
| + | |||
| + | Copy it to ''/usr/local/share/ca-certificates/'': | ||
| + | <code> | ||
| + | sudo cp ca.crt /usr/local/share/ca-certificates/ | ||
| + | </code> | ||
| + | Then: | ||
| + | <code> | ||
| + | sudo update-ca-certificates | ||
| + | </code> | ||
| + | And finish restarting docker: ''sudo service docker restart'' | ||
| + | |||
| + | |||
| + | It also could require to add the registry to insecure registries in ''/etc/docker/daemon.json'': | ||
| + | <code> | ||
| + | { | ||
| + | "insecure-registries": [ "nexus.jamgo.org:5000", "hubapp.seuicab.net:5000" ], | ||
| + | "features": { "buildkit": true } | ||
| + | } | ||
| + | </code> | ||