0% found this document useful (0 votes)
89 views5 pages

Docker Container Practices Guide

1. The document discusses creating an interactive Docker container using the Fedora image and exploring the system. Commands like uname, yum, and wget are demonstrated. 2. An upgrade is performed inside the container and wget is installed to demonstrate package management. 3. The running container is exited and stopped, and the processes are listed to show the container is no longer active.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views5 pages

Docker Container Practices Guide

1. The document discusses creating an interactive Docker container using the Fedora image and exploring the system. Commands like uname, yum, and wget are demonstrated. 2. An upgrade is performed inside the container and wget is installed to demonstrate package management. 3. The running container is exited and stopped, and the processes are listed to show the container is no longer active.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Apasoft Training

Prácticas Docker
1. Contenedores interactivos
• Vamos a crear un contenedor interactivo con una imagen de Fedora

docker run -it fedora bash


[root@c284d12f3db6 /]#
• Podemos ver los datos del sistema operativo

uname -a
Linux c284d12f3db6 3.10.0-693.11.1.el7.x86_64 #1 SMP Mon
Dec 4 [Link] UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
• Desde otro terminal, comprobamos si el contenedor está activo

docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
c284d12f3db6 fedora "bash"
26 minutes ago Up 26 minutes
jolly_clarke
• Podemos ver las imágenes donde está la que acabamos de descargar

docker images
REPOSITORY TAG IMAGE ID
CREATED SIZE
fedora latest 9110ae7f579f
8 days ago 235MB
busybox latest f6e427c148a7
2 weeks ago 1.15MB
hello-world latest f2a91732366c
3 months ago 1.85kB
• Hacemos por ejemplo un upgrade del sistema

yum upgrade
Fedora 27 - x86_64 - Updates 2.5 MB/s |
21 MB 00:08
Fedora 27 - x86_64 2.2 MB/s |
58 MB 00:26
Last metadata expiration check: [Link] ago on Fri Mar 16
[Link] 2018.
[Link]
[Link]@[Link] 1
Apasoft Training

Dependencies resolved.
==========================================================
======================
Package Arch Version
Repository Size
==========================================================
======================
Upgrading:
audit-libs x86_64 2.8.3-1.fc27
updates 112 k
glibc x86_64 2.26-27.fc27
updates 3.4 M
glibc-common x86_64 2.26-27.fc27
updates 789 k
glibc-langpack-en x86_64 2.26-27.fc27
updates 278 k
libblkid x86_64 2.30.2-2.fc27
updates 196 k
libcrypt-nss x86_64 2.26-27.fc27
updates 40 k
libfdisk x86_64 2.30.2-2.fc27
updates 244 k
libmount x86_64 2.30.2-2.fc27
updates 219 k
libsmartcols x86_64 2.30.2-2.fc27
updates 160 k
libsss_idmap x86_64 1.16.0-8.fc27
updates 88 k
libsss_nss_idmap x86_64 1.16.0-8.fc27
updates 94 k
libunistring x86_64 0.9.9-1.fc27
updates 417 k
libuuid x86_64 2.30.2-2.fc27
updates 82 k
p11-kit x86_64 0.23.10-1.fc27
updates 263 k
p11-kit-trust x86_64 0.23.10-1.fc27
updates 135 k
pcre x86_64 8.41-6.fc27
updates 205 k

[Link]
[Link]@[Link] 2
Apasoft Training

……

• Intentamos hacer un wget y vemos que no existe

wget
bash: wget: command not found
• Lo instalamos

yum install wget


Last metadata expiration check: [Link] ago on Fri Mar 16
[Link] 2018.
Dependencies resolved.
==========================================================
======================
Package Arch Version
Repository Size
==========================================================
======================
Installing:
wget x86_64 1.19.4-1.fc27
updates 726 k

Transaction Summary
==========================================================
======================
Install 1 Package

Total download size: 726 k


Installed size: 2.8 M
Is this ok [y/N]:
• Ya podemos usarlo:

wget [Link]
--2018-03-16 [Link]-- [Link]
Resolving [Link] ([Link])... [Link],
[Link], [Link]
Connecting to [Link]
([Link])|[Link]|:80... connected.
[Link]
[Link]@[Link] 3
Apasoft Training

HTTP request sent, awaiting response... 301 Moved


Permanently
Location: [Link] [following]
--2018-03-16 [Link]-- [Link]
Connecting to [Link]
([Link])|[Link]|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 43210 (42K) [text/html]
Saving to: '[Link]'

[Link] 100%[===================>] 42.20K --


.-KB/s in 0.06s

2018-03-16 [Link] (676 KB/s) - '[Link]' saved


[43210/43210]
• Hacemos un exit del contenedor
• Podemos comprobar que ya no está activo, que ese encuentra entre los
parados

docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES

docker ps -a
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
c284d12f3db6 fedora "bash"
About an hour ago Exited (127) 7 seconds ago
jolly_clarke
f639beed83d0 busybox "sh"
21 hours ago Exited (0) 21 hours ago
nifty_vaughan
ac6d243d4bcc hello-world "/hello"
21 hours ago Exited (0) 21 hours ago
loving_jennings
0e7ef0959d21 hello-world "/hello"
21 hours ago Exited (0) 21 hours ago
festive_davinci

[Link]
[Link]@[Link] 4
Apasoft Training

• Ahora lo volvemos a arrancar. En mi caso, el contenedor tiene el id


c284d12f3db6. Podemos usar solo los 4 primeros caracteres

docker start -i c284


[root@c284d12f3db6 /]#
• Desde otro terminal lo vamos a parar y comprobamos

docker stop c284


c284
docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES

docker ps -a
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
c284d12f3db6 fedora "bash"
About an hour ago Exited (0) 6 seconds ago
jolly_clarke
f639beed83d0 busybox "sh"
21 hours ago Exited (0) 21 hours ago
nifty_vaughan
ac6d243d4bcc hello-world "/hello"
21 hours ago Exited (0) 21 hours ago
loving_jennings
0e7ef0959d21 hello-world "/hello"
21 hours ago Exited (0) 21 hours ago
festive_davinci

[Link]
[Link]@[Link] 5

You might also like