Docker series: 8. Exercise: Create Shellinabox Image and run as a container

Jay Bilgaye
cloudscoop
Published in
2 min readOct 5, 2019
  1. Create a Docker file as below
[root@machine1 myImage2]# cat Dockerfile
FROM centos:latest
MAINTAINER jack sparrow
RUN yum install -y wget
RUN wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
RUN rpm -ivh epel-release-7–11.noarch.rpm
RUN yum install -y openssl shellinabox

2. Build the Docker image

root@machine1 myImage2]# docker build -t mycentos:shellinabox .
Sending build context to Docker daemon 2.048kB
Step 1/6 : FROM centos:latest
— -> 9f38484d220f
Step 2/6 : MAINTAINER jack sparrow
— -> Using cache
— -> 1e611ab8dcdb
Step 3/6 : RUN yum install -y wget
— -> Using cache
— -> 5a8cd6130712
Step 4/6 : RUN wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
— -> Using cache
— -> eab836875ad9
Step 5/6 : RUN rpm -ivh epel-release-7–11.noarch.rpm
— -> Using cache
— -> c4a53e106880
Step 6/6 : RUN yum install -y openssl shellinabox
— -> Using cache
— -> f69399f06c35
Successfully built f69399f06c35
Successfully tagged mycentos:shellinabox

3. Run the image

root@machine1 myImage2]# docker run -t -d -P — name shellinabox mycentos:shellinabox
e39e1d9d4d40a5ca0476656bf0ad17fe0e549a54b3595b733b4960f70949767f
[root@machine1 myImage2]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e39e1d9d4d40 mycentos:shellinabox “/bin/bash” 23 seconds ago Up 22 seconds

4. Login to container and check package installed or not.

[root@machine1 myImage2]# docker run -it mycentos:shellinabox
[root@422e186a9259 /]#yum info shellinabox
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.viethosting.com
* epel: download.nus.edu.sg
* extras: mirrors.viethosting.com
* updates: mirror.horizon.vn
Installed Packages
Name : shellinabox
Arch : x86_64
Version : 2.20
Release : 5.el7
Size : 503 k
Repo : installed
From repo : epel
Summary : Web based AJAX terminal emulator
URL : https://github.com/shellinabox/shellinabox
License : GPLv2
Description : Shell In A Box implements a web server that can export arbitrary command line
: tools to a web based terminal emulator. This emulator is accessible to any
: JavaScript and CSS enabled web browser and does not require any additional
: browser plugins.
[root@422e186a9259 /]# exit[root@machine1 myImage2]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e39e1d9d4d40 mycentos:shellinabox “/bin/bash” 4 minutes ago Up 4 minutes shellinabox
[root@machine1 myImage2]#

5. Stop the container

[root@machine1 myImage2]# docker container stop e39e1d9d4d40
docker e39e1d9d4d40
[root@machine1 myImage2]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@machine1 myImage2]#

Series next read;

https://medium.com/cloudscoop/cloudscoop-docker-series-working-with-docker-compose-e9fd5f66388d

--

--