Example search (for tomcat) images on Docker Hub

docker search tomcat

Download image

without starting the container. example with Wordpress image.

docker pull wordpress


See local (downloaded) images

docker images
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
tomcat Apache Tomcat is an open source implementati… 2701 [OK]
tomee Apache TomEE is an all-Apache Java EE certif… 77 [OK]
dordoka/tomcat Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 base… 53 [OK]
bitnami/tomcat Bitnami Tomcat Docker Image 31 [OK]
kubeguide/tomcat-app Tomcat image for Chapter 1 28
consol/tomcat-7.0 Tomcat 7.0.57, 8080, "admin/admin" 17 [OK]
cloudesire/tomcat Tomcat server, 6/7/8 15 [OK]
aallam/tomcat-mysql Debian, Oracle JDK, Tomcat & MySQL 12 [OK]
arm32v7/tomcat Apache Tomcat is an open source implementati… 10
rightctrl/tomcat CentOS , Oracle Java, tomcat application ssl… 6 [OK]
maluuba/tomcat7-java8 Tomcat7 with java8. 4


...
REPOSITORY TAG IMAGE ID CREATED SIZE
wordpress php7.4-fpm-alpine 78ac3963ff95 2 weeks ago 201MB
amazonlinux latest cd2d92bc1c0c 2 weeks ago 163MB
php 7.4-fpm-alpine 0e798217e66f 3 weeks ago 81.4MB


See running images

docker ps

Run container example

Interactive mode start

of tomcat with mapping port 8080 of container to 8080 on server

docker run -it -p 8080:8080 tomcat

Background start

docker run -d 8080:8080 tomcat


Delete images

work if no running containers on that image

docker rmi wordpress


Create Custom docker image using Dockerfile


vi Dockerfile
Dockerfile
FROM amazonlinux

RUN yum -y update
RUN yum -y install httpd
RUN yum -y install php

COPY ./index.php /var/www/html/index.php

CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]

EXPOSE 80
index.php
<?php phpinfo(); ?>

Build an image

using Dockerfile in current "." directory

docker build --tag example/amzn-phpinfo .

See image info

docker image history example/amzn-phpinfo
IMAGE CREATED CREATED BY SIZE COMMENT
77066f284dea 2 minutes ago /bin/sh -c #(nop) EXPOSE 80 0B
ee2fcebe08bb 2 minutes ago /bin/sh -c #(nop) CMD ["/usr/sbin/httpd" "-… 0B
ac29f44aa839 2 minutes ago /bin/sh -c #(nop) COPY file:7aa92ce52044b7f0… 20B
9352d0227e03 2 minutes ago /bin/sh -c yum -y install php 203MB
47ac5b8a84d6 3 minutes ago /bin/sh -c yum -y install httpd 255MB
0e2161f5a988 3 minutes ago /bin/sh -c yum -y update 193MB
cd2d92bc1c0c 2 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 2 weeks ago /bin/sh -c #(nop) ADD file:119ae574c5d5b6e59… 163MB
docker image inspect example/amzn-phpinfo


Optimize size of custom docker image using Dockerfile 

use one RUN instead of 3 RUN commands

FROM amazonlinux

RUN yum -y update && yum -y install httpd && yum -y install php

COPY ./index.php /var/www/html/index.php

CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]

EXPOSE 80

docker build --tag example/amzn-phpinfo2 .
docker images

Compare images size

REPOSITORY TAG IMAGE ID CREATED SIZE
example/amzn-phpinfo2 latest 09cfca98bf82 6 seconds ago 446MB
example/amzn-phpinfo latest 77066f284dea About an hour ago 814MB


docker image history example/amzn-phpinfo


IMAGE CREATED CREATED BY SIZE COMMENT
8778eaa349e0 15 seconds ago /bin/sh -c #(nop) EXPOSE 80 0B
76ae852f36aa 16 seconds ago /bin/sh -c #(nop) CMD ["/usr/sbin/httpd" "-… 0B
04073f3bdeb5 16 seconds ago /bin/sh -c #(nop) COPY file:7aa92ce52044b7f0… 20B
5fae081a55c5 17 seconds ago /bin/sh -c yum -y install php 203MB
d3de1d44ef67 32 seconds ago /bin/sh -c yum -y install httpd 255MB
79133349b929 About a minute ago /bin/sh -c yum -y update 193MB
cd2d92bc1c0c 2 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 2 weeks ago /bin/sh -c #(nop) ADD file:119ae574c5d5b6e59… 163MB
docker image history example/amzn-phpinfo2
IMAGE CREATED CREATED BY SIZE COMMENT
09cfca98bf82 4 minutes ago /bin/sh -c #(nop) EXPOSE 80 0B
e0f8728488e3 4 minutes ago /bin/sh -c #(nop) CMD ["/usr/sbin/httpd" "-… 0B
fe1e985876af 4 minutes ago /bin/sh -c #(nop) COPY file:7aa92ce52044b7f0… 20B
4f0abf0cea3b 4 minutes ago /bin/sh -c yum -y update && yum -y install h… 283MB
cd2d92bc1c0c 2 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 2 weeks ago /bin/sh -c #(nop) ADD file:119ae574c5d5b6e59… 163MB

Update image from the running or stopped container

sudo docker run -d -p 8000:80 kyivtank/amzn-phpinfo
docker exec -it e90a9e1ec094 bash
echo "<?php echo 'Current PHP version: ' . phpversion(); ?>" >/var/www/html/version.php
exit
docker ps


CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                                      NAMES
6aa53631dccd        kyivtank/amzn-phpinfo         "/usr/sbin/httpd -D …"   5 minutes ago       Up 5 minutes        0.0.0.0:8000->80/tcp                       gracious_antonelli
docker commit  --message "Add version.php" 6aa53631dccd kyivtank/amzn-phpinfo2
docker image history kyivtank/amzn-phpinfo2
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
f6ed0e8c64ec        About an hour ago   /usr/sbin/httpd -D FOREGROUND                   3kB                 Add version.php
09cfca98bf82        2 hours ago         /bin/sh -c #(nop)  EXPOSE 80                    0B
<missing>           2 hours ago         /bin/sh -c #(nop)  CMD ["/usr/sbin/httpd" "-…   0B
<missing>           2 hours ago         /bin/sh -c #(nop) COPY file:7aa92ce52044b7f0…   20B
<missing>           2 hours ago         /bin/sh -c yum -y update && yum -y install h…   283MB
<missing>           2 weeks ago         /bin/sh -c #(nop)  CMD ["/bin/bash"]            0B
<missing>           2 weeks ago         /bin/sh -c #(nop) ADD file:119ae574c5d5b6e59…   163MB


Push to Docker hub

docker login
docker push kyivtank/amzn-phpinfo2

remove unused docker images

docker image prune -a
  • No labels