Herramientas de usuario

Herramientas del sitio


wiki2:docker-examples

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
wiki2:docker-examples [2018/12/28 13:02]
alfred [Definir un proxy en el build]
wiki2:docker-examples [2022/10/19 16:37] (actual)
Línea 1: Línea 1:
 ====== Docker Notes ====== ====== Docker Notes ======
  
 +===== Dockerfile'​s examples =====
 +
 +//​Dockerfile.svn//​
 +<​code>​
 +FROM alpine:3.9
 +
 +RUN apk update
 +RUN apk add subversion
 +
 +WORKDIR /srv
 +
 +CMD ["​svnserve",​ "​-d",​ "​--foreground",​ "​-r",​ "/​srv"​]
 +
 +# You can build it with:
 +# docker build -f Dockerfile.svn --build-arg http_proxy=http://​172.16.1.60:​3128 -t svn .
 +
 +# Run it with:
 +# docker run svn
 +# Or even better:
 +# docker run -p 3690:3690 -v /​home/​alfred/​tmp/​svnsrv:/​srv --name svn svn
 +
 +# To enter to it you'll do:
 +# docker run -ti svn sh
 +
 +# Then, to create repos:
 +# docker exec svn svnadmin create new-repo
 +
 +# From now you can do:
 +# svn checkout svn://​127.0.0.1/​new-repo
 +</​code>​
 ===== docker-compose examples ===== ===== docker-compose examples =====
 <​code>​ <​code>​
Línea 85: 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 139: Línea 172:
 docker rmi $(docker images -q) docker rmi $(docker images -q)
 </​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 148: 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>​
  
wiki2/docker-examples.1546002137.txt.gz · Última modificación: 2020/05/09 09:24 (editor externo)