How to Create Web Server In Docker Container By Using Port Expose
In this article,we will see Create Web Server In Docker Container by using Port Expose.
Steps to Follow
- Create a Dominized Container “ktexperts-webserver” with image “ubuntu” and port mapping 80:80.
- Go inside the container “ktexperts-webserver”.
- Update Server Available Packages.
- Install webserver package “apache2”.
- Go inside “/var/www/html” directory and create a file “index.html”.
- Start apache2 service.
- Verify content of container “ktexperts-webserver”.
To see the list of all images
1 2 |
[root@ip-172-31-4-99 ec2-user]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE |
To see the list of all containers
1 2 |
[root@ip-172-31-4-99 ec2-user]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
1. Create a Dominized Container “ktexperts-webserver” with image “ubuntu” and port mapping 80:80
1 2 3 4 5 6 7 8 9 10 |
[root@ip-172-31-4-99 ec2-user]# docker run -td --name ktexperts-webserver -p 80:80 ubuntu Unable to find image 'ubuntu:latest' locally latest: Pulling from library/ubuntu 2746a4a261c9: Pull complete 4c1d20cdee96: Pull complete 0d3160e1d0de: Pull complete c8e37668deea: Pull complete Digest: sha256:250cc6f3f3ffc5cdaa9d8f4946ac79821aafb4d3afc93928f0de9336eba21aa4 Status: Downloaded newer image for ubuntu:latest c47768516a3e7b03d82aee2fd42911f09936b9851ca8668331f3c12a5d7a5821 |
To see the list of running containers
1 2 3 |
[root@ip-172-31-4-99 ec2-user]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c47768516a3e ubuntu "/bin/bash" 2 minutes ago Up 2 minutes 0.0.0.0:80->80/tcp ktexperts-webserver |
2. Go inside the container “ktexperts-webserver”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@ip-172-31-4-99 ec2-user]# docker exec -it ktexperts-webserver /bin/bash root@c47768516a3e:/# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var root@c47768516a3e:/# cat /etc/os-release NAME="Ubuntu" VERSION="18.04.3 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.3 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic |
3. Update Server Available Packages
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
root@c47768516a3e:/# apt-get update Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] Get:2 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB] Get:3 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [6781 B] Get:4 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [21.8 kB] Get:5 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [803 kB] Get:6 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Get:7 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB] Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1344 kB] Get:9 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [777 kB] Get:10 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [13.5 kB] Get:11 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB] Get:12 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB] Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [10.8 kB] Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1325 kB] Get:15 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [1074 kB] Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [35.5 kB] Get:17 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [4241 B] Get:18 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [2496 B] Fetched 17.4 MB in 4s (4612 kB/s) Reading package lists... Done |
4. Install webserver package “apache2”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
root@c47768516a3e:/# apt-get install apache2 -y Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: apache2-bin apache2-data apache2-utils file libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libasn1-8-heimdal libexpat1 libgdbm-compat4 libgdbm5 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal libicu60 libkrb5-26-heimdal libldap-2.4-2 libldap-common liblua5.2-0 libmagic-mgc libmagic1 libnghttp2-14 libperl5.26 libroken18-heimdal libsasl2-2 libsasl2-modules libsasl2-modules-db libsqlite3-0 libssl1.1 libwind0-heimdal libxml2 mime-support netbase openssl perl perl-modules-5.26 ssl-cert xz-utils Suggested packages: www-browser apache2-doc apache2-suexec-pristine | apache2-suexec-custom ufw gdbm-l10n libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap libsasl2-modules-otp libsasl2-modules-sql ca-certificates perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make openssl-blacklist The following NEW packages will be installed: apache2 apache2-bin apache2-data apache2-utils file libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libasn1-8-heimdal libexpat1 libgdbm-compat4 libgdbm5 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal libicu60 libkrb5-26-heimdal libldap-2.4-2 libldap-common liblua5.2-0 libmagic-mgc libmagic1 libnghttp2-14 libperl5.26 libroken18-heimdal libsasl2-2 libsasl2-modules libsasl2-modules-db libsqlite3-0 libssl1.1 libwind0-heimdal libxml2 mime-support netbase openssl perl perl-modules-5.26 ssl-cert xz-utils 0 upgraded, 42 newly installed, 0 to remove and 1 not upgraded. Need to get 21.0 MB of archives. After this operation, 99.4 MB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 perl-modules-5.26 all 5.26.1-6ubuntu0.3 [2763 kB] Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgdbm5 amd64 1.14.1-6 [26.0 kB] Get:3 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgdbm-compat4 amd64 1.14.1-6 [6084 B] Get:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libperl5.26 amd64 5.26.1-6ubuntu0.3 [3527 kB] Get:5 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 perl amd64 5.26.1-6ubuntu0.3 [201 kB] Get:6 http://archive.ubuntu.com/ubuntu bionic/main amd64 mime-support all 3.60ubuntu1 [30.1 kB] Get:7 http://archive.ubuntu.com/ubuntu bionic/main amd64 libapr1 amd64 1.6.3-2 [90.9 kB] Get:8 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libexpat1 amd64 2.2.5-3ubuntu0.2 [80.5 kB] Get:9 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libssl1.1 amd64 1.1.1-1ubuntu2.1~18.04.5 [1300 kB] Get:10 http://archive.ubuntu.com/ubuntu bionic/main amd64 libaprutil1 amd64 1.6.1-2 [84.4 kB] Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libsqlite3-0 amd64 3.22.0-1ubuntu0.2 [498 kB] Get:12 http://archive.ubuntu.com/ubuntu bionic/main amd64 libaprutil1-dbd-sqlite3 amd64 1.6.1-2 [10.6 kB] Get:13 http://archive.ubuntu.com/ubuntu bionic/main amd64 libroken18-heimdal amd64 7.5.0+dfsg-1 [41.3 kB] Get:14 http://archive.ubuntu.com/ubuntu bionic/main amd64 libasn1-8-heimdal amd64 7.5.0+dfsg-1 [175 kB] Get:15 http://archive.ubuntu.com/ubuntu bionic/main amd64 libheimbase1-heimdal amd64 7.5.0+dfsg-1 [29.3 kB] Get:16 http://archive.ubuntu.com/ubuntu bionic/main amd64 libhcrypto4-heimdal amd64 7.5.0+dfsg-1 [85.9 kB] Get:17 http://archive.ubuntu.com/ubuntu bionic/main amd64 libwind0-heimdal amd64 7.5.0+dfsg-1 [47.8 kB] Get:18 http://archive.ubuntu.com/ubuntu bionic/main amd64 libhx509-5-heimdal amd64 7.5.0+dfsg-1 [107 kB] Get:19 http://archive.ubuntu.com/ubuntu bionic/main amd64 libkrb5-26-heimdal amd64 7.5.0+dfsg-1 [206 kB] Get:20 http://archive.ubuntu.com/ubuntu bionic/main amd64 libheimntlm0-heimdal amd64 7.5.0+dfsg-1 [14.8 kB] Get:21 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgssapi3-heimdal amd64 7.5.0+dfsg-1 [96.5 kB] Get:22 http://archive.ubuntu.com/ubuntu bionic/main amd64 libsasl2-modules-db amd64 2.1.27~101-g0780600+dfsg-3ubuntu2 [14.8 kB] Get:23 http://archive.ubuntu.com/ubuntu bionic/main amd64 libsasl2-2 amd64 2.1.27~101-g0780600+dfsg-3ubuntu2 [49.2 kB] Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libldap-common all 2.4.45+dfsg-1ubuntu1.4 [16.9 kB] Get:25 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libldap-2.4-2 amd64 2.4.45+dfsg-1ubuntu1.4 [155 kB] Get:26 http://archive.ubuntu.com/ubuntu bionic/main amd64 libaprutil1-ldap amd64 1.6.1-2 [8764 B] Get:27 http://archive.ubuntu.com/ubuntu bionic/main amd64 liblua5.2-0 amd64 5.2.4-1.1build1 [108 kB] Get:28 http://archive.ubuntu.com/ubuntu bionic/main amd64 libnghttp2-14 amd64 1.30.0-1ubuntu1 [77.8 kB] Get:29 http://archive.ubuntu.com/ubuntu bionic/main amd64 libicu60 amd64 60.2-3ubuntu3 [8054 kB] Get:30 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libxml2 amd64 2.9.4+dfsg1-6.1ubuntu1.2 [663 kB] Get:31 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2-bin amd64 2.4.29-1ubuntu4.11 [1071 kB] Get:32 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2-utils amd64 2.4.29-1ubuntu4.11 [83.9 kB] Get:33 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2-data all 2.4.29-1ubuntu4.11 [160 kB] Get:34 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2 amd64 2.4.29-1ubuntu4.11 [95.1 kB] Get:35 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmagic-mgc amd64 1:5.32-2ubuntu0.3 [184 kB] Get:36 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmagic1 amd64 1:5.32-2ubuntu0.3 [68.7 kB] Get:37 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 file amd64 1:5.32-2ubuntu0.3 [22.1 kB] Get:38 http://archive.ubuntu.com/ubuntu bionic/main amd64 netbase all 5.4 [12.7 kB] Get:39 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 openssl amd64 1.1.1-1ubuntu2.1~18.04.5 [613 kB] Get:40 http://archive.ubuntu.com/ubuntu bionic/main amd64 xz-utils amd64 5.2.2-1.3 [83.8 kB] Get:41 http://archive.ubuntu.com/ubuntu bionic/main amd64 libsasl2-modules amd64 2.1.27~101-g0780600+dfsg-3ubuntu2 [48.7 kB] Get:42 http://archive.ubuntu.com/ubuntu bionic/main amd64 ssl-cert all 1.0.39 [17.0 kB] Fetched 21.0 MB in 4s (5216 kB/s) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package perl-modules-5.26. (Reading database ... 4046 files and directories currently installed.) Preparing to unpack .../00-perl-modules-5.26_5.26.1-6ubuntu0.3_all.deb ... Unpacking perl-modules-5.26 (5.26.1-6ubuntu0.3) ... Selecting previously unselected package libgdbm5:amd64. Preparing to unpack .../01-libgdbm5_1.14.1-6_amd64.deb ... Unpacking libgdbm5:amd64 (1.14.1-6) ... Selecting previously unselected package libgdbm-compat4:amd64. Preparing to unpack .../02-libgdbm-compat4_1.14.1-6_amd64.deb ... Unpacking libgdbm-compat4:amd64 (1.14.1-6) ... Selecting previously unselected package libperl5.26:amd64. Preparing to unpack .../03-libperl5.26_5.26.1-6ubuntu0.3_amd64.deb ... Unpacking libperl5.26:amd64 (5.26.1-6ubuntu0.3) ... Selecting previously unselected package perl. Preparing to unpack .../04-perl_5.26.1-6ubuntu0.3_amd64.deb ... Unpacking perl (5.26.1-6ubuntu0.3) ... Selecting previously unselected package mime-support. Preparing to unpack .../05-mime-support_3.60ubuntu1_all.deb ... Unpacking mime-support (3.60ubuntu1) ... Selecting previously unselected package libapr1:amd64. Preparing to unpack .../06-libapr1_1.6.3-2_amd64.deb ... Unpacking libapr1:amd64 (1.6.3-2) ... Selecting previously unselected package libexpat1:amd64. Preparing to unpack .../07-libexpat1_2.2.5-3ubuntu0.2_amd64.deb ... Unpacking libexpat1:amd64 (2.2.5-3ubuntu0.2) ... Selecting previously unselected package libssl1.1:amd64. Preparing to unpack .../08-libssl1.1_1.1.1-1ubuntu2.1~18.04.5_amd64.deb ... Unpacking libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.5) ... Selecting previously unselected package libaprutil1:amd64. Preparing to unpack .../09-libaprutil1_1.6.1-2_amd64.deb ... Unpacking libaprutil1:amd64 (1.6.1-2) ... Selecting previously unselected package libsqlite3-0:amd64. Preparing to unpack .../10-libsqlite3-0_3.22.0-1ubuntu0.2_amd64.deb ... Unpacking libsqlite3-0:amd64 (3.22.0-1ubuntu0.2) ... Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64. Preparing to unpack .../11-libaprutil1-dbd-sqlite3_1.6.1-2_amd64.deb ... Unpacking libaprutil1-dbd-sqlite3:amd64 (1.6.1-2) ... Selecting previously unselected package libroken18-heimdal:amd64. Preparing to unpack .../12-libroken18-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libroken18-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libasn1-8-heimdal:amd64. Preparing to unpack .../13-libasn1-8-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libasn1-8-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libheimbase1-heimdal:amd64. Preparing to unpack .../14-libheimbase1-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libheimbase1-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libhcrypto4-heimdal:amd64. Preparing to unpack .../15-libhcrypto4-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libhcrypto4-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libwind0-heimdal:amd64. Preparing to unpack .../16-libwind0-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libwind0-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libhx509-5-heimdal:amd64. Preparing to unpack .../17-libhx509-5-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libhx509-5-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libkrb5-26-heimdal:amd64. Preparing to unpack .../18-libkrb5-26-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libkrb5-26-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libheimntlm0-heimdal:amd64. Preparing to unpack .../19-libheimntlm0-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libheimntlm0-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libgssapi3-heimdal:amd64. Preparing to unpack .../20-libgssapi3-heimdal_7.5.0+dfsg-1_amd64.deb ... Unpacking libgssapi3-heimdal:amd64 (7.5.0+dfsg-1) ... Selecting previously unselected package libsasl2-modules-db:amd64. Preparing to unpack .../21-libsasl2-modules-db_2.1.27~101-g0780600+dfsg-3ubuntu2_amd64.deb ... Unpacking libsasl2-modules-db:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2) ... Selecting previously unselected package libsasl2-2:amd64. Preparing to unpack .../22-libsasl2-2_2.1.27~101-g0780600+dfsg-3ubuntu2_amd64.deb ... Unpacking libsasl2-2:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2) ... Selecting previously unselected package libldap-common. Preparing to unpack .../23-libldap-common_2.4.45+dfsg-1ubuntu1.4_all.deb ... Unpacking libldap-common (2.4.45+dfsg-1ubuntu1.4) ... Selecting previously unselected package libldap-2.4-2:amd64. Preparing to unpack .../24-libldap-2.4-2_2.4.45+dfsg-1ubuntu1.4_amd64.deb ... Unpacking libldap-2.4-2:amd64 (2.4.45+dfsg-1ubuntu1.4) ... Selecting previously unselected package libaprutil1-ldap:amd64. Preparing to unpack .../25-libaprutil1-ldap_1.6.1-2_amd64.deb ... Unpacking libaprutil1-ldap:amd64 (1.6.1-2) ... Selecting previously unselected package liblua5.2-0:amd64. Preparing to unpack .../26-liblua5.2-0_5.2.4-1.1build1_amd64.deb ... Unpacking liblua5.2-0:amd64 (5.2.4-1.1build1) ... Selecting previously unselected package libnghttp2-14:amd64. Preparing to unpack .../27-libnghttp2-14_1.30.0-1ubuntu1_amd64.deb ... Unpacking libnghttp2-14:amd64 (1.30.0-1ubuntu1) ... Selecting previously unselected package libicu60:amd64. Preparing to unpack .../28-libicu60_60.2-3ubuntu3_amd64.deb ... Unpacking libicu60:amd64 (60.2-3ubuntu3) ... Selecting previously unselected package libxml2:amd64. Preparing to unpack .../29-libxml2_2.9.4+dfsg1-6.1ubuntu1.2_amd64.deb ... Unpacking libxml2:amd64 (2.9.4+dfsg1-6.1ubuntu1.2) ... Selecting previously unselected package apache2-bin. Preparing to unpack .../30-apache2-bin_2.4.29-1ubuntu4.11_amd64.deb ... Unpacking apache2-bin (2.4.29-1ubuntu4.11) ... Selecting previously unselected package apache2-utils. Preparing to unpack .../31-apache2-utils_2.4.29-1ubuntu4.11_amd64.deb ... Unpacking apache2-utils (2.4.29-1ubuntu4.11) ... Selecting previously unselected package apache2-data. Preparing to unpack .../32-apache2-data_2.4.29-1ubuntu4.11_all.deb ... Unpacking apache2-data (2.4.29-1ubuntu4.11) ... Selecting previously unselected package apache2. Preparing to unpack .../33-apache2_2.4.29-1ubuntu4.11_amd64.deb ... Unpacking apache2 (2.4.29-1ubuntu4.11) ... Selecting previously unselected package libmagic-mgc. Preparing to unpack .../34-libmagic-mgc_1%3a5.32-2ubuntu0.3_amd64.deb ... Unpacking libmagic-mgc (1:5.32-2ubuntu0.3) ... Selecting previously unselected package libmagic1:amd64. Preparing to unpack .../35-libmagic1_1%3a5.32-2ubuntu0.3_amd64.deb ... Unpacking libmagic1:amd64 (1:5.32-2ubuntu0.3) ... Selecting previously unselected package file. Preparing to unpack .../36-file_1%3a5.32-2ubuntu0.3_amd64.deb ... Unpacking file (1:5.32-2ubuntu0.3) ... Selecting previously unselected package netbase. Preparing to unpack .../37-netbase_5.4_all.deb ... Unpacking netbase (5.4) ... Selecting previously unselected package openssl. Preparing to unpack .../38-openssl_1.1.1-1ubuntu2.1~18.04.5_amd64.deb ... Unpacking openssl (1.1.1-1ubuntu2.1~18.04.5) ... Selecting previously unselected package xz-utils. Preparing to unpack .../39-xz-utils_5.2.2-1.3_amd64.deb ... Unpacking xz-utils (5.2.2-1.3) ... Selecting previously unselected package libsasl2-modules:amd64. Preparing to unpack .../40-libsasl2-modules_2.1.27~101-g0780600+dfsg-3ubuntu2_amd64.deb ... Unpacking libsasl2-modules:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2) ... Selecting previously unselected package ssl-cert. Preparing to unpack .../41-ssl-cert_1.0.39_all.deb ... Unpacking ssl-cert (1.0.39) ... Setting up libapr1:amd64 (1.6.3-2) ... Setting up libexpat1:amd64 (2.2.5-3ubuntu0.2) ... Setting up libicu60:amd64 (60.2-3ubuntu3) ... Setting up libnghttp2-14:amd64 (1.30.0-1ubuntu1) ... Setting up mime-support (3.60ubuntu1) ... Setting up libldap-common (2.4.45+dfsg-1ubuntu1.4) ... Setting up libsasl2-modules-db:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2) ... Setting up libsasl2-2:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2) ... Setting up apache2-data (2.4.29-1ubuntu4.11) ... Setting up libroken18-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up perl-modules-5.26 (5.26.1-6ubuntu0.3) ... Setting up libgdbm5:amd64 (1.14.1-6) ... Setting up libxml2:amd64 (2.9.4+dfsg1-6.1ubuntu1.2) ... Setting up libmagic-mgc (1:5.32-2ubuntu0.3) ... Setting up libmagic1:amd64 (1:5.32-2ubuntu0.3) ... Setting up libssl1.1:amd64 (1.1.1-1ubuntu2.1~18.04.5) ... debconf: unable to initialize frontend: Dialog debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.) debconf: falling back to frontend: Readline Setting up xz-utils (5.2.2-1.3) ... update-alternatives: using /usr/bin/xz to provide /usr/bin/lzma (lzma) in auto mode update-alternatives: warning: skip creation of /usr/share/man/man1/lzma.1.gz because associated file /usr/share/man/man1/xz.1.gz (of link group lzma) doesn't exist update-alternatives: warning: skip creation of /usr/share/man/man1/unlzma.1.gz because associated file /usr/share/man/man1/unxz.1.gz (of link group lzma) doesn't exist update-alternatives: warning: skip creation of /usr/share/man/man1/lzcat.1.gz because associated file /usr/share/man/man1/xzcat.1.gz (of link group lzma) doesn't exist update-alternatives: warning: skip creation of /usr/share/man/man1/lzmore.1.gz because associated file /usr/share/man/man1/xzmore.1.gz (of link group lzma) doesn't exist update-alternatives: warning: skip creation of /usr/share/man/man1/lzless.1.gz because associated file /usr/share/man/man1/xzless.1.gz (of link group lzma) doesn't exist update-alternatives: warning: skip creation of /usr/share/man/man1/lzdiff.1.gz because associated file /usr/share/man/man1/xzdiff.1.gz (of link group lzma) doesn't exist update-alternatives: warning: skip creation of /usr/share/man/man1/lzcmp.1.gz because associated file /usr/share/man/man1/xzcmp.1.gz (of link group lzma) doesn't exist update-alternatives: warning: skip creation of /usr/share/man/man1/lzgrep.1.gz because associated file /usr/share/man/man1/xzgrep.1.gz (of link group lzma) doesn't exist update-alternatives: warning: skip creation of /usr/share/man/man1/lzegrep.1.gz because associated file /usr/share/man/man1/xzegrep.1.gz (of link group lzma) doesn't exist update-alternatives: warning: skip creation of /usr/share/man/man1/lzfgrep.1.gz because associated file /usr/share/man/man1/xzfgrep.1.gz (of link group lzma) doesn't exist Setting up libaprutil1:amd64 (1.6.1-2) ... Setting up libheimbase1-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up openssl (1.1.1-1ubuntu2.1~18.04.5) ... Setting up libsqlite3-0:amd64 (3.22.0-1ubuntu0.2) ... Setting up liblua5.2-0:amd64 (5.2.4-1.1build1) ... Setting up libgdbm-compat4:amd64 (1.14.1-6) ... Setting up libsasl2-modules:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2) ... Setting up netbase (5.4) ... Setting up libwind0-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libaprutil1-dbd-sqlite3:amd64 (1.6.1-2) ... Setting up apache2-utils (2.4.29-1ubuntu4.11) ... Setting up libasn1-8-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libhcrypto4-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up ssl-cert (1.0.39) ... debconf: unable to initialize frontend: Dialog debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.) debconf: falling back to frontend: Readline Setting up file (1:5.32-2ubuntu0.3) ... Setting up libhx509-5-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libperl5.26:amd64 (5.26.1-6ubuntu0.3) ... Setting up libkrb5-26-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libheimntlm0-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up perl (5.26.1-6ubuntu0.3) ... Setting up libgssapi3-heimdal:amd64 (7.5.0+dfsg-1) ... Setting up libldap-2.4-2:amd64 (2.4.45+dfsg-1ubuntu1.4) ... Setting up libaprutil1-ldap:amd64 (1.6.1-2) ... Setting up apache2-bin (2.4.29-1ubuntu4.11) ... Setting up apache2 (2.4.29-1ubuntu4.11) ... Enabling module mpm_event. Enabling module authz_core. Enabling module authz_host. Enabling module authn_core. Enabling module auth_basic. Enabling module access_compat. Enabling module authn_file. Enabling module authz_user. Enabling module alias. Enabling module dir. Enabling module autoindex. Enabling module env. Enabling module mime. Enabling module negotiation. Enabling module setenvif. Enabling module filter. Enabling module deflate. Enabling module status. Enabling module reqtimeout. Enabling conf charset. Enabling conf localized-error-pages. Enabling conf other-vhosts-access-log. Enabling conf security. Enabling conf serve-cgi-bin. Enabling site 000-default. invoke-rc.d: could not determine current runlevel invoke-rc.d: policy-rc.d denied execution of start. Processing triggers for libc-bin (2.27-3ubuntu1) ... |
5. Go inside “/var/www/html” directory and create a file “index.html”
1 2 3 4 5 6 |
root@c47768516a3e:/# cd /var/www/html root@c47768516a3e:/var/www/html# echo "Ktexperts is a knowledge sharing platform" > index.html root@c47768516a3e:/var/www/html# ls index.html root@c47768516a3e:/var/www/html# cat index.html Ktexperts is a knowledge sharing platform |
6. Start apache2 service
1 2 3 4 5 |
root@c47768516a3e:/var/www/html# service apache2 start * Starting Apache httpd web server apache2 /usr/sbin/apache2ctl: 99: ulimit: error setting limit (Operation not permitted) Setting ulimit failed. See README.Debian for more information. AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message * |
Verify status of apache2 service
1 2 |
root@c47768516a3e:/var/www/html# service apache2 status * apache2 is running |
7. Verify content of container “ktexperts-webserver”
Generally container won’t have any IP that’s why we expose the ports in both sides then give Docker Public IPV4 to users.
They can access container webserver through docker.
Copy Public IPV4 of the Docker
Search IPV4 Public IP along with default port and file in browser
We can see default port “80” and default file “index.html”
13.232.52.198:80/index.html is default port (80) and file(index.html).
Search IPV4 Public IP of Docker in browser
The default port “80” and default file “index.html” so,we no need to give the path directly we can give IPV4 Public IP of Docker.
Key Points
Demonized Mode (Even Though you exit from container,those will be running).
Container is running without going inside the container.
Map 2 ports while running the docker run command.
one port for base machine (Docker) and another one for container (ktexperts-webserver).
We can change host port but can’t container port.
Port 80 is the default port.
Container don’t have any IP Address but it has port.
We access the container web content through base machine IP Address.
Thank you for giving your valuable time to read the above information.
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTEXPERTS is always active on below social media platforms.
Facebook : https://www.facebook.com/ktexperts/
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform