...
Code Block |
---|
sudo apt install docker.io |
Adding a current user to the docker group to avoid sudo prefix in all docker commands
Code Block |
---|
sudo usermod -aG docker $USER |
Example search (for tomcat) images on Docker Hub
Code Block |
---|
docker search tomcat |
Download image
without starting container. example with wordpress image.
Code Block |
---|
docker pull wordpress |
See local (downloaded) images
...
Panel |
---|
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
Run container example
Interactive mode start
of tomcat with mapping port 8080 of container to 8080 on server
Code Block |
---|
docker run -it -p 8080:8080 tomcat |
Background start
Code Block |
---|
docker run -d 8080:8080 tomcat |
Delete images
work if no running containers on that image
Code Block |
---|
docker rmi wordpress |
Create Custom docker image using Dockerfile
Code Block |
---|
|
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 |
Code Block |
---|
|
<?php phpinfo(); ?> |
Build image
Code Block |
---|
docker build --tag example/amzn-phpinfo . |
See image info
Code Block |
---|
docker image history example/amzn-phpinfo |
Panel |
---|
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 |
Code Block |
---|
docker image inspect example/amzn-phpinfo |