Herramientas de usuario

Herramientas del sitio


wiki2:docker-new

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-new [2018/12/12 07:07]
alfred [Images]
wiki2:docker-new [2022/02/20 10:54] (actual)
Línea 21: Línea 21:
 ''​docker start <​container id>''​ ''​docker start <​container id>''​
  
 +=== Create an image and run a command over it without starting ===
 +<​code>​
 +docker build -f dockerfile.app -t coop .
 +docker run -ti coop python ​
 +</​code>​
 ==== Info about containers ==== ==== Info about containers ====
  
Línea 37: Línea 42:
 ''​docker logs <​container id>''​ ''​docker logs <​container id>''​
  
 +First, if you just need to see less output, you can have docker only show you the more recent lines:
 +<​code>​docker logs --since 30s -f <​container_name_or_id></​code>​
 +Or you can put a number of lines to limit:
 +<​code>​docker logs --tail 20 -f <​container_name_or_id></​code>​
 ==== Stop containers ==== ==== Stop containers ====
  
Línea 59: Línea 68:
 </​code>​ </​code>​
  
 +=== So... ===
 +The idea would be:
 +  - ''​Build''​ an image.
 +  - ''​Run''​ the container. Maybe in daemon mode (-d). It will give you an id.
 +  - ''​Exec''​ a command, for example sh, into the container id.
 +  - ''​Ps''​ the id if required.
 +  - ''​Kill''​ the id.
  
 +<​code>​
 +docker build --build-arg http_proxy=http://​192.168.40.110:​3128 -t svn .
 +LASTID=`docker run -d -p 80:80 svn`
 +docker exec -ti $LASTID sh
 +docker kill $LASTID
 +</​code>​
 ==== Images ==== ==== Images ====
 +=== List images ===
 +<​code>​
 +docker images
 +docker images debian
 +</​code>​
 +
 === Build the Dockerfile in the current path === === Build the Dockerfile in the current path ===
 <​code>​ <​code>​
Línea 66: Línea 94:
 </​code>​ </​code>​
  
 +Doing it setting a proxy:
 +<​code>​
 +docker build --build-arg HTTP_PROXY=http://<​ip>:<​port>​ .
 +</​code>​
  
 === Tagging an image === === Tagging an image ===
Línea 77: Línea 109:
  
  
-=== List images ===+=== Rename o re-tagging an image === 
 +<​code>​docker tag server:​latest myname/​server:​latest</​code>​ 
 +or 
 +<​code>​docker tag d583c3ac45fd myname/​server:​latest</​code>​ 
 + 
 +=== Basic commands with images ===
 <​code>​ <​code>​
 docker image ls docker image ls
 docker image --all # o -a, show intermediate images docker image --all # o -a, show intermediate images
-docker image prune # removes the unused+docker image prune  
 +docker image prune -a # removes the unused
 docker image inspect # shows info about the image docker image inspect # shows info about the image
 +</​code>​
 +
 +==== Stats and info ====
 +<​code>​
 +docker stats
 +</​code>​
 +Info of sizes:
 +<​code>​
 +docker system df -v
 +</​code>​
 +Info about containers:
 +<​code>​
 +docker ps --size
 </​code>​ </​code>​
 ===== Docker compose ===== ===== Docker compose =====
Línea 110: Línea 161:
 </​code>​ </​code>​
 Then: ''​env DJANGO_SETTINGS_MODULE=OpenAwards.settings.production docker-coompose up''​ Then: ''​env DJANGO_SETTINGS_MODULE=OpenAwards.settings.production docker-coompose up''​
 +
 +
 +===== Shortcuts =====
 +Imaginemos que tienes un Dockerfile sin **CMD** definido, podrías construir el contenedor con:
 +<​code>​
 +docker build -f Dockerfile.svn -t svn .
 +</​code>​
 +Y luego correr dentro de él con:
 +<​code>​
 +docker run -ti svn sh
 +</​code>​
wiki2/docker-new.1544598438.txt.gz · Última modificación: 2020/05/09 09:24 (editor externo)