Self-Paced Training (1) - Introduction to Docker
helloworld:
wget -qo- https://get.docker.com/ | sh sudo docker run hello-world sudo usermod -aG docker johnnytu docker run hello-world
Install Docker
- Follow the instructions at https://docs.docker.com/installation/ to install the latest Docker maintained Docker package on your preferred operating system
- Run the hello-world container to test your installation: sudo docker run hello-world
- Add your user account to the docker group: sudo user mod -aG docker <user>
- Logout of your terminal and log back in for the changes to take effect
- 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
- Go to https://hub.docker.com/account/signup/ and signup for an account if you do not already have one
- Find your confirmation email and activate your account
- Browse some of the repositories
- 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
- 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
- In your container, create a new user using your first and last name as the username: adduser <username>
- Add the user to the sudo group: adduser <username> sudo
- Exit the container: exit
- Notice how the container shut down
- Once again run: sudo docker run -i -t ubuntu:14.04 /bin/bash
- Try and find your user
- 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
- docker run -d centos:7 ping 127.0.0.1 -c 50
- List your containers by running: docker ps
- Notice the cents container running
- run: docker ps -a
- 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
- docker run -d -P tomcat:7
- Check your image details by running docker ps
- 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
- Go to <your linux server url>:<port number> and verify that you can see the Tomcat page
Self-Paced Training (1) - Introduction to Docker的更多相关文章
- Training - An Introduction to Enterprise Integration
What is EI? Enterprise Integration (EI) is a business computing term for the plans, methods, and too ...
- Docker Resources
Menu Main Resources Books Websites Documents Archives Community Blogs Personal Blogs Videos Related ...
- Docker基本使用(二)
Docker 客户端 我们可以直接输入 docker 命令来查看到 Docker 客户端的所有命令选项. 可以通过命令 docker command --help 更深入的了解指定的 Docker 命 ...
- Docker记录-Docker部署记录
1.Docker介绍 Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从Apache2.0协议开源. Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级.可移植的容器中,然后 ...
- Docker学习笔记1 -- 刚入手docker时的几个命令
目录 Hello World 后台运行 停止运行 容器 载入镜像 指定端口映射 查看日志 查看应用的进程 登入镜像内部 移除容器 镜像 查看本地镜像 拉取镜像 查找镜像 更新镜像 构建镜像 设置镜像标 ...
- Docker入门 - 004 Docker 容器使用
Docker 客户端 docker 客户端非常简单 ,我们可以直接输入 docker 命令来查看到 Docker 客户端的所有命令选项. docker 可以通过命令 docker command -- ...
- docker 的使用
docker 学习 1. Docker 允许你在容器内运行应用程序, 使用 docker run 命令来在容器内运行一个应用程序. 输出Hello world docker run ubuntu:15 ...
- Docker简单使用
镜像是一种轻量级.可执行的独立软件包,它包含运行某个软件所需的所有内容,包括代码.运行时.库.环境变量和配置文件. 容器是镜像的运行时实例 - 实际执行时镜像会在内存中变成什么.默认情况下,它完全独立 ...
- Docker 核心技术与实现原理
提到虚拟化技术,我们首先想到的一定是 Docker,经过四年的快速发展 Docker 已经成为了很多公司的标配,也不再是一个只能在开发阶段使用的玩具了.作为在生产环境中广泛应用的产品,Docker 有 ...
随机推荐
- 谈谈python 中__name__ = '__main__' 的作用
最近刚刚学习python,看到别人的源代码中经常出现这样一个代码段: if __name__ = '__main__' dosomting() 觉得很晕,不知道这段代码的作用是什么,后来上网查了一些资 ...
- 使用saltstack批量部署服务器运行环境事例——批量部署nagios客户端
之前关于搭建web服务器集群实验的这篇文章http://www.cnblogs.com/cjyfff/p/3553579.html中,关于如何用saltstack批量部署服务器这一点当时没有记录到文章 ...
- Eclipse开发Android报错Jar mismatch! Fix your dependencies
常常打开工程,发现项目并没有错,但是会有一个红X,然后就生成不了. 发现两个版本不同的android-support-v4.jar在使用 打开window-show views-problems Ja ...
- MySQL 5.1.63 单机配置多实例(简单配置)
需求: 在一台服务器上通过源码编译安装一个版本为5.1.63版本MySQL数据库: 方案:将所有配置文件与数据等均存放在/home/zhaoshuangshuang下.在同一个MySQL中运行两个实例 ...
- js高级技巧笔记(一)
安全的类型检测 Js的类型检测机制并非完全可靠,发生错误否定及错误肯定的情况也不少: 在safari 在对正则表达式应用typeof操作符时返回"function",因此很难确定某 ...
- Indri中的动态文档索引技术
Indri中的动态文档索引技术 戴维 译 摘要: Indri 动态文档索引的实现技术,支持在更新索引的同时处理用户在线查询请求. 文本搜索引擎曾被设计为针对固定的文档集合进行查询,对不少应用来说,这种 ...
- python学习笔记15(面向对象编程)
虽然Python是解释性语言,但是它是面向对象的,能够进行对象编程. 一.如何定义一个类 在进行python面向对象编程之前,先来了解几个术语:类,类对象,实例对象,属性,函数和方法. 类是对现实世界 ...
- 如何修改SVN中的用户名和密码
删除掉C:\Users\Administrator\Application Data\Subversion\auth\svn.simple文件夹下的文件即可.再次访问时,会弹出要求输入用户名和密码. ...
- 然爸读书笔记(2014-10)----Bootsrap用户手册
本来其实这方面的知识,可以直接在网站上看,但是自己是web前端的小白.基本不懂.所以,还是买一本书来看,更好些.体现出我对前端的重视. Bootstrap是快速开发Web应用程序的前端工具包.它是一个 ...
- 指针 取地址& 解引用 *
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAtAAAACNCAIAAAARutrLAAAgAElEQVR4nOydd3wcxd3/R13uvdsUY2