0% found this document useful (0 votes)
49 views

Prácticas Docker: 1. Contenedores Interactivos

1. The document discusses creating an interactive Docker container using the Fedora image and running commands inside the container such as updating packages and installing new packages like wget. 2. It shows how to start and stop the container and check its status. 3. The goal is to demonstrate how to run interactive containers and install/use common Linux commands inside the container.
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)
49 views

Prácticas Docker: 1. Contenedores Interactivos

1. The document discusses creating an interactive Docker container using the Fedora image and running commands inside the container such as updating packages and installing new packages like wget. 2. It shows how to start and stop the container and check its status. 3. The goal is to demonstrate how to run interactive containers and install/use common Linux commands inside the container.
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
You are on page 1/ 5

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 23:52:40 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: 0:00:06 ago on Fri Mar 16
11:20:28 2018.
www.apasoft-training.com
[email protected] 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

www.apasoft-training.com
[email protected] 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: 0:08:23 ago on Fri Mar 16
11:20:28 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 www.oracle.com
--2018-03-16 11:35:07-- http://www.oracle.com/
Resolving www.oracle.com (www.oracle.com)... 2.19.165.3,
2a02:26f0:13c:280::366, 2a02:26f0:13c:294::366
Connecting to www.oracle.com
(www.oracle.com)|2.19.165.3|:80... connected.
www.apasoft-training.com
[email protected] 3
Apasoft Training

HTTP request sent, awaiting response... 301 Moved


Permanently
Location: https://www.oracle.com/index.html [following]
--2018-03-16 11:35:07-- https://www.oracle.com/index.html
Connecting to www.oracle.com
(www.oracle.com)|2.19.165.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 43210 (42K) [text/html]
Saving to: 'index.html'

index.html 100%[===================>] 42.20K --


.-KB/s in 0.06s

2018-03-16 11:35:08 (676 KB/s) - 'index.html' 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

www.apasoft-training.com
[email protected] 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

www.apasoft-training.com
[email protected] 5

You might also like