helloworld:

wget -qo- https://get.docker.com/ | sh

sudo docker run hello-world

sudo usermod -aG docker johnnytu

docker run hello-world

Install Docker

  1. Follow the instructions at https://docs.docker.com/installation/ to install the latest Docker maintained Docker package on your preferred operating system
  2. Run the hello-world container to test your installation: sudo docker run hello-world
  3. Add your user account to the docker group: sudo user mod -aG docker <user>
  4. Logout of your terminal and log back in for the changes to take effect
  5. Verify that you can run the hello-world container without using sudo: docker run hello-world

sudo docker version

Docker Machine

Tools that provisions Docker hosts and installs the Docker Engine on them

Docker Swarm

Tools that clusters many Engines and schedules containers

Docker Compose

Tools to create and manage multi-container applications

Create a Docker Hub Account

  1. Go to https://hub.docker.com/account/signup/ and signup for an account if you do not already have one
  2. Find your confirmation email and activate your account
  3. Browse some of the repositories
  4. Search for some images of your favorite dev tools, languages, servers etc… examples: Java, Perl, Maven, Tomcat, NGINX, Apache

Display local image

sudo docker images

Creating a Container

sudo docker run [options] [image] [command] [args]

image is specified with repository:tag

Examples

docker run ubuntu:14.04 echo “hello world”

docker run ubuntu ps ax

docker run -i -t ubuntu:14.04 /bin/bash

The -i flag tells docker to connect to STDIN on the container

The -t flag specifies to get a pseudo-terminal

Run a Container and get Terminal Access

  1. Create a container using the ubuntu 14.04 image and connect to STDIN and a terminal: sudo docker run -i -t ubuntu:14.04 /bin/bash
  2. In your container, create a new user using your first and last name as the username: adduser <username>
  3. Add the user to the sudo group: adduser <username> sudo
  4. Exit the container: exit
  5. Notice how the container shut down
  6. Once again run: sudo docker run -i -t ubuntu:14.04 /bin/bash
  7. Try and find your user
  8. Notice that it does not exist

Ctrl + P + Q

Container ID

Containers can be specified using their ID or name

Long ID and short ID

Short ID and name can be obtained using docker ps command to list containers

Long ID obtained by inspecting a container

Running in Detached Mode

Also known as running in the background or as a daemon

Use -d flag

To observe output use docker logs <container id>

docker run -d centos: ping 127.0.0.1 -c 

List Your Containers

  1. docker run -d centos:7 ping 127.0.0.1 -c 50
  2. List your containers by running: docker ps
  3. Notice the cents container running
  4. run: docker ps -a
  5. Notice all the containers created from the previous exercises

A More Practical Container

Run a web application inside a container

The -P flag to map container ports to host ports

Create a container using the tomcat image, run in detached mode and map the tomcat ports to the host port: docker run -d -P tomcat:7

Run a Web Application Container

  1. docker run -d -P tomcat:7
  2. Check your image details by running docker ps
  3. Notice the port mapping. The container’s port 8080 is mapped to a random port on your host machine: 0.0.0.0:49155->8080/tcp
  4. Go to <your linux server url>:<port number> and verify that you can see the Tomcat page

Self-Paced Training (1) - Introduction to Docker的更多相关文章

  1. Training - An Introduction to Enterprise Integration

    What is EI? Enterprise Integration (EI) is a business computing term for the plans, methods, and too ...

  2. Docker Resources

    Menu Main Resources Books Websites Documents Archives Community Blogs Personal Blogs Videos Related ...

  3. Docker基本使用(二)

    Docker 客户端 我们可以直接输入 docker 命令来查看到 Docker 客户端的所有命令选项. 可以通过命令 docker command --help 更深入的了解指定的 Docker 命 ...

  4. Docker记录-Docker部署记录

    1.Docker介绍 Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从Apache2.0协议开源. Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级.可移植的容器中,然后 ...

  5. Docker学习笔记1 -- 刚入手docker时的几个命令

    目录 Hello World 后台运行 停止运行 容器 载入镜像 指定端口映射 查看日志 查看应用的进程 登入镜像内部 移除容器 镜像 查看本地镜像 拉取镜像 查找镜像 更新镜像 构建镜像 设置镜像标 ...

  6. Docker入门 - 004 Docker 容器使用

    Docker 客户端 docker 客户端非常简单 ,我们可以直接输入 docker 命令来查看到 Docker 客户端的所有命令选项. docker 可以通过命令 docker command -- ...

  7. docker 的使用

    docker 学习 1. Docker 允许你在容器内运行应用程序, 使用 docker run 命令来在容器内运行一个应用程序. 输出Hello world docker run ubuntu:15 ...

  8. Docker简单使用

    镜像是一种轻量级.可执行的独立软件包,它包含运行某个软件所需的所有内容,包括代码.运行时.库.环境变量和配置文件. 容器是镜像的运行时实例 - 实际执行时镜像会在内存中变成什么.默认情况下,它完全独立 ...

  9. Docker 核心技术与实现原理

    提到虚拟化技术,我们首先想到的一定是 Docker,经过四年的快速发展 Docker 已经成为了很多公司的标配,也不再是一个只能在开发阶段使用的玩具了.作为在生产环境中广泛应用的产品,Docker 有 ...

随机推荐

  1. IE11下ASP.NET Forms身份认证无法保存Cookie的问题

    IE11下ASP.NET Forms身份认证无法保存Cookie的问题 折腾了三四天,今天才找到资料,解决了. 以下会转贴,还没来得及深究,先放着,有空再学习下. ASP.NET中使用Forms身份认 ...

  2. cxgrid HyperLink 鼠标显示效果

    procedure TForm1.cxGrid1DBTableView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); v ...

  3. CentOS7安装nagios并配置出图详解

    目录 开始之前 系统环境 监控内容 所需软件包 台机器,全都按照CentOS7最小化模式安装系统 系统版本号 [root@localhost ~]# cat  /etc/redhat-release ...

  4. springmvc整合redis架构搭建实例

    新换环境,又有新东西可以学习了,哈皮! 抽空学习之余看了一下redis,个人对Springmvc的爱是忠贞不渝,所以整理了一下Springmvc整合redis的环境搭建.分享学习. 第一步: 创建ma ...

  5. 语音合成,语音播报功能(系统)-b

    第一次接触语音合成,只实现了很简单的功能,记录一下,以后免得去网上四处找资料 最近在做高德地图导航的时候有个语音播报的功能,高德sdk已经提供了要语音的字符串.我要做的就是把这些字符串读出声音来即可. ...

  6. 360随身wifi怎样购买?360随身wifi怎样预约?

    ---恢复内容开始--- 360随身wifi怎样购买 想要购买360随身Wifi,可以登录360随身Wifi的官网wifi.360.cn,或者直接登陆京东商城进行购买,售价为19.9元,分黑.白两色. ...

  7. Javascript中Array.prototype.map()详解

    map 方法会给原数组中的每个元素都按顺序调用一次 callback 函数.callback 每次执行后的返回值组合起来形成一个新数组. callback 函数只会在有值的索引上被调用:那些从来没被赋 ...

  8. codeforces #309 div1 C

    首先我们会发现所有的人构成了一个图 定义相爱为 在一个集合里 定义相恨为 不在一个集合里 很容易发现满足条件的图一定是一个二分图 那么分类讨论如下: 1.如果出现不合法 答案为0 2.如果不是一个二分 ...

  9. mybatis怎样配置数据库集群

    场景:一个读数据源一个读写数据源. 原理:借助spring的[org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource] ...

  10. [Unity菜鸟] Unity鼠标双击,鼠标函数整理(未完)

    1. 鼠标双击 void OnGUI() { Event Mouse = Event.current; if (Mouse.isMouse && Mouse.type == Event ...