Docker.pdf


Vista previa del archivo PDF docker.pdf


Página 1...83 84 85868791

Vista previa de texto


CMD ["/bin/echo" , "Hi Docker !"]

Construimos la nueva imagen:
docker build .

Ejecutamos un contenedor a partir de esta:
docker run 99fac58824c2
Hi Docker!

Y ahora sobreescribiendo el comando:
docker run 99fac58824c2 /bin/date
Thu Mar 17 00:14:00 UTC 2016

Si el Dockerfile utiliza la instrucción ENTRYPOINT y necesitamos hacer override, se
le puede pasar la opción --entrypoint al docker run.
Tenemos una imagen creada, pero como verán no tiene un tag y siempre nos
referimos a ella por su IMAGE ID. Para esto podemos hacer un rebuild usando la
opción -t.
$ docker build -t ubuntu-echo:1.0.0 .
...
...
REPOSITORY
TAG
VIRTUAL SIZE
ubuntu-echo
1.0.0
ago
187.9 MB
...

IMAGE ID
99fac58824c2

CREATED
About an hour

Podemos colocarle el nombre que querramos, pero siempre es mejor seguir las
convenciones :)
<name-of-recipe>:<version-of-recipe>

El comando build tiene una serie de opciones configurables y pueden verse con
la opcion -h
$ docker build -h
Usage:

docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile
--build-arg=[]
--cpu-shares=0
--cgroup-parent=
--cpu-period=0
Scheduler) period
--cpu-quota=0
Scheduler) quota
--cpuset-cpus=
--cpuset-mems=
--disable-content-trust=true
-f, --file=
'PATH/Dockerfile')
--force-rm=false
--help=false
-m, --memory=
--memory-swap=
disable swap

Set build-time variables
CPU shares (relative weight)
Optional parent cgroup for the container
Limit the CPU CFS (Completely Fair
Limit the CPU CFS (Completely Fair
CPUs
MEMs
Skip
Name

in which to allow execution (0-3, 0,1)
in which to allow execution (0-3, 0,1)
image verification
of the Dockerfile (Default is

Always remove intermediate containers
Print usage
Memory limit
Total memory (memory + swap), '-1' to