You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

Install Docker

sudo apt install docker.io

Adding a current user to the docker group to avoid sudo prefix in all docker commands

sudo usermod -aG docker $USER

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



  • No labels