Docker 一小时从入门到实战 —— Docker commands | Create your own image | vs VM ... 基本概念扫盲

Docker crash course

1. What and Why of Docker?

2.1 What

image-20240131232702960

2.2 What problem does it solve?

2.2.1 before containers

Development process before containers? If your app uses 10 services, each developer needs to install these 10 services.

image-20240131232953257

Development process:

image-20240131234204271

  • Installations and configurations done directly on server’s OS
  • Dependency version conflicts etc.
  • image-20240131234503249

2.1.2 with containers

Development process with containers? Standardizes process of running any services on any local dev environment.

image-20240131233322529

image-20240131233809511

Development process:

  • Install Docker runtime on the server
  • Run Docker command to fetch and run Docker artifacts.

image-20240131234657955

2. Docker vs Virtual Machines

image-20240201222936730

2.1 Difference

image-20240201223239644

docker

  • contains the OS application layer - vertualize complete OS
  • services and apps installed on top that layer

image-20240201223642154

image-20240201223903860

2.2 Benefits

image-20240201224514428

image-20240201225004644

  • most containers are Linux based
  • Originally built for Linux OS

upgrade –

image-20240201225248641

image-20240201225439201

3. Install docker locally

image-20240201225835186

image-20240201225945915

4. Images vs Containers

image-20240202174026601

image-20240202174304374

image-20240202174335917

	docker imagesdocker ps = list running contaniers 

5. Public and Private Registries

How do we get these images?

image-20240202175312917

image-20240202175753612

image-20240202191255815

6. Main Docker commands - pull,run,start,stop,logs,build

6.1 pull & run

Pull Docker Hub registry (docker.io) is used by default.

	docker pull {name}:{tag} = Pull an image from a registrydocker images

Run

	docker run {name}:{tag} = creates a container from given images and starts itdocker ps
  • docker generates a random name for the container automatically if you don’t specify one
  • docker pulls image automatically, if it doesn’t find it locally.
	docker -d = runs container in background and prints the container ID

you may still want to see the logs,which can be useful for debugging etc.

	docker logs {container} = view logs from service running inside the container.

give a name --name

docker run --name web-app -d -p 9000:80 nginx:1.23

Port Binding

image-20240202201259784

image-20240202201341689

localhost:80 cannot be reached

image-20240202201434320

only run with additional tag:

image-20240202201657337

image-20240202203541008

	docker stop {container} = stop one or more running containers
	-p or --publish = pubish a container's port to the host-p {HOST_PORT}:{CONTAINER_PORT}

all in all

	docker run -d -p 9000:80 niginx:1.23

image-20240202230203135

image-20240203180806189

6.2 start & stop

image-20240203180858684

docker ps only list the running containers. To list all containers (stopped and running) by using flag -a or --all

docker ps -a

stop

docker stop {containerID}

start

docker start {containerID} = start one or more stopped containers

logs

docker logs {containerID/NAME}

7. Public and private Docker registries

image-20240203225855787

image-20240203234521430

8. Registry vs Repository

image-20240203235721998

image-20240204000022806

image-20240204000125110

9. Create own image (Dockerfile)

image-20240205165439067

image-20240205165757421

9.1 Dockerfile - Build instruction

image-20240205165827894

image-20240205165844694

image-20240205165913517

image-20240205171226680

image-20240205171323341

image-20240205171445885

image-20240205210256610

image-20240205210713734

image-20240205211146261

image-20240205211320662

image-20240205211412241

	CMD ["node", "server.js"]

image-20240205211619780

9.2 Build image

	docker build {path} = Builds a Docker image from a Dockerfile

Sets a name and optionally a tag in the “name:tag” format

	docker build -t node-app:1.0 .

image-20240205214951661

image-20240205215035997

9.3 Run as Docker container

image-20240205215254016

9.4 Docker UI Client

10. Image Versioning

image-20240202191521178

“latest” tag mostly refers to the newest release.

11. Docker Compose

12. Docker Workflow Big Picture

How Docker fits in the complete development and development process?

image-20240205221128201

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/465896.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

CentOS7下如何安装Nginx

一、Ngxin是什么 Nginx是一个开源的 Web 服务器,具有反向代理、负载均衡、缓存等功能。它可以作为 HTTP 服务器,将服务器上的静态文件(如 HTML、图片)通过 HTTP 协议展现给客户端,也可以实现动静分离,把动态…

寒假9-蓝桥杯训练

//轨道炮 #include<iostream> using namespace std; #include<algorithm> int logs[100010]; int main() {int n;cin >> n;for (int i 1;i < n;i){cin >> logs[i];}sort(logs 1, logs n 1);int ans 1000000000;for (int i 2;i < n;i){if (…

{}初始化和初始化列表

C98标准中允许使用花括号对数组和自定义类型的变量进行初始化&#xff0c;C11扩展了大括号的用途&#xff0c;允许使用花括号对所有的内置类型和自定义类型进行初始化&#xff0c;使用时&#xff0c;可以加号&#xff0c;也可以不加。 对于自定义类型&#xff0c;当花括号中的常…

Obsidian Publish的开源替代品Perlite

前几天就有网友跟我说&#xff0c;freenom 的免费域名不可用了&#xff0c;10 号的时候老苏进后台看了一下&#xff0c;还有一半的域名显示为 ACTIVE&#xff0c;似乎是以 2024年6月 为限。但到 11 号&#xff0c;老苏发现博客 (https://laosu.cf) 已经访问不了了&#xff0c;这…

OpenMVG(EXIF、畸变、仿射特征、特征匹配)

本人之前也研究过OpenMVS但是对于OpenMVG只是原理层次的了解&#xff0c;因此乘着过年期间对这个库进行详细的学习。 目录 1 OpenMVG编译与简单测试 1.1 sfm_data.json获取 1.2 计算特征 2 OpenMVG整个流程的运行测试 3 OpenMVG实战 3.1 SVG绘制 3.2 解析图片的EXIF信息…

前沿重器[42] | self-RAG-大模型决策的典型案例探究

前沿重器 栏目主要给大家分享各种大厂、顶会的论文和分享&#xff0c;从中抽取关键精华的部分和大家分享&#xff0c;和大家一起把握前沿技术。具体介绍&#xff1a;仓颉专项&#xff1a;飞机大炮我都会&#xff0c;利器心法我还有。&#xff08;算起来&#xff0c;专项启动已经…

WordPress修改所有用户名并发送邮件通知的插件Easy Username Updater

前面跟大家介绍了『如何修改WordPress后台管理员用户名&#xff1f;推荐2种简单方法』一文&#xff0c;但是对于有很多用户的站长来说&#xff0c;操作有点复杂&#xff0c;而且无法发邮件通知对方&#xff0c;所以今天boke112百科向大家推荐一款可以直接在WordPress后台修改所…

关于Navicat导入sql文件后er图乱序问题

关于Navicat导入sql文件后er图乱序问题 具体操作如下&#xff1a; 点击左下角刷新旁边的小三角

Bootstrap学习三

Bootstrap学习三 文章目录 前言四、Bootstrap插件4.1. 插件概览4.1.1. data属性4.1.2. 编程方式的API4.1.3. 避免命名空间冲突4.1.4. 事件 4.2. 模态框4.2.1. 引入4.2.2. 基本结构4.2.3. 基本使用4.2.4. 触发模态框的方法 4.3. 下拉菜单和滚动监听4.3.1. 下拉菜单4.3.2. 滚动监…

第三节课[LangChain]作业

文章目录 前言实践搭建向量知识库 前言 本次作业虽然是第三节课作业&#xff0c;但是在第四次作业之后才完成&#xff0c;所以用的是经过自我认知微调的小助手权重。 使用**诡秘之主和宿命之环小说&#xff08;仅用于学习和研究&#xff09;**以及设定集、百度百科&#xff0c…

C++ //练习 5.21 修改5.5.1节(第171页)练习题的程序,使其找到的重复单词必须以大写字母开头。

C Primer&#xff08;第5版&#xff09; 练习 5.21 练习 5.21 修改5.5.1节&#xff08;第171页&#xff09;练习题的程序&#xff0c;使其找到的重复单词必须以大写字母开头。 环境&#xff1a;Linux Ubuntu&#xff08;云服务器&#xff09; 工具&#xff1a;vim 代码块 /…

第六篇【传奇开心果系列】Vant of Vue 开发移动应用示例:深度解析响应式布局支持

传奇开心果系列 系列博文目录Vant开发移动应用示例系列 博文目录前言一、Vant响应式布局介绍二、媒体查询实现响应式布局示例代码三、短点设置实现响应式布局示例代码四、响应式工具类实现响应式布局示例代码五、栅格系统实现响应式布局示例代码六、响应式组件实现响应式布局示…