Apt Install Docker



Alternatively, you can actively enter container sessions by running docker run -it ubuntu bash command and execute the further apt-get install nginx command. While the command is running, detach from the container using Ctrl-p + Ctrl-q keys and the container will continue running even if the Nginx installation process finishes. Docker 安装 Tomcat 方法一、docker pull tomcat 查找 Docker Hub 上的 Tomcat 镜像: 可以通过 Sort by 查看其他版本的 tomcat,默认是最新版本 tomcat:latest。 此外,我们还可以用 docker search tomcat 命令来查看可用版本: runoob@runoob:/tomcat$ docker search tomcat NAME.

Docker 安装 Python

方法一、docker pull tomcat

查找 Docker Hub 上的 Tomcat 镜像:

可以通过 Sort by 查看其他版本的 tomcat,默认是最新版本 tomcat:latest

此外,我们还可以用 docker search tomcat 命令来查看可用版本:

这里我们拉取官方的镜像:

等待下载完成后,我们就可以在本地镜像列表里查到 REPOSITORY 为 tomcat 的镜像。

方法二、通过 Dockerfile 构建

创建Dockerfile

首先,创建目录tomcat,用于存放后面的相关东西。

webapps 目录将映射为 tomcat 容器配置的应用程序目录。

logs 目录将映射为 tomcat 容器的日志目录。

conf 目录里的配置文件将映射为 tomcat 容器的配置文件。

进入创建的 tomcat 目录,创建 Dockerfile。

通过 Dockerfile 创建一个镜像,替换成你自己的名字:

创建完成后,我们可以在本地的镜像列表里查找到刚刚创建的镜像:

使用 tomcat 镜像

运行容器

命令说明:

-p 8080:8080:将主机的 8080 端口映射到容器的 8080 端口。

-v $PWD/test:/usr/local/tomcat/webapps/test:将主机中当前目录下的 test 挂载到容器的 /test。

查看容器启动情况

通过浏览器访问

Docker 安装 Python

This tutorial explains, how to install docker on EC2 Instance. Before starting, let’s have some brief knowledge about Docker.

Docker is a platform that combines applications and its dependencies in the form of packages, called container. We can run multiple containers on a single Operating System. Containers are not Virtual Machines. Virtual Machines requires Operating System to run applications, but containers do not. As containers don’t need an Operating System, it takes very little time to start and hence it is very faster than Virtual Machines.

Also Learn: How to install Ansible on Amazon Linux(EC2 )

and Launching Amazon Linux EC2 Instance

Let’s Install Docker on EC2 Instance

In this tutorial, we will use Amazon Linux to install docker. Amazon Linux/Amazon Linux2 is the Linux Operating System used in EC2 Instance.

Step 1– Log to Linux EC2 Instance and update it.

$ sudo yum update -y

Apt Install Docker

Step 2– Install docker using Yum command

$ sudo yum install docker -y

Step 3– Start Docker Service

$ Service docker start

Step 4– Check docker Version.

$ docker -v

Apt Install Docker-ce

Basic Configuration (Creating Docker File / Running Docker Image)

After you install docker on ec2 , let’s have some basic setup for Docker.

Step 1 – Create a docker file

Dockerfile is a text file where we write instructions to build an image.

Create a folder name Images on the Amazon Linux box.

$ mkdir images

Move to folder images

$ cd images

Create a file name Dockerfile inside images folder

$ nano Dockerfile

Put the content in the following way inside the Dockerfile.

FROM Ubuntu ( It will use the Official image Ubuntu to build your image)

MAINTAINER chandan <[email protected]>

( It sets the Author field of the generated image)

RUN apt-get update ( It will update the image at the time of Build)

CMD [ “echo”, ” Hello World ……….! “] ( It will run echo command when we run the docker container image)

Please also readHow to install docker on ec2 Instance(Windows)

You may also likeInstall Docker on Ubuntu using Script

Step 2– Run the docker build command to build the image.

$ docker build .

Note : ( . command is used when you are inside images folder where Dockerfile is present, alternatively you can put the docker file absolute path like /home/ec2-user/images/Dockerfile)

You can run the following command as well to Name and tag your Image. Here myimage is the Name and 01 is Tag of the image.

$ docker build -t myimage:01 .

Step 3– See the Docker Images after build

$ docker images

Step 4 – Run the docker image

$ docker run 07deaa33585e

Here 07deaa33585e is the IMAGE ID that can be seen in docker images command.

You can see here, it executed the echo command as soon as we run the docker image. In the same way, we can run any script, commands or any application by running a docker image.

Click to tweet this tip !

Apt Install Docker Debian

I hope you enjoyed this tutorial and learned to install docker on ec2 instance (Amazon Linux). If you think this is really helpful, please do share this with others as well. Please also share your valuable feedback, comment or any query in the comment box. I will really happy to resolve your all queries anytime.

Apt Install Docker Vs Docker.io

Thank You

If you think we helped you or just want to support us, please consider these:-

Apt install docker vs docker.io

Apt Install Docker Ubuntu 20.04

Connect to us: Facebook | Twitter