Docker使用分享

2021-07-28 12:49:04 字數 3958 閱讀 7783

通過dockerfile構建docker映象

遇到的問題

[root@5a25c7e57895 ~]# cat /etc/redhat-release

centos

linux release 7.3.1611 (core)

yum install -y docker
[root@5a25c7e57895 ~]# systemctl start docker.service

failed to get d-bus connection: operation not permitted

[root@d96182175e58 ~]# systemctl enable docker.service

operation failed: no such file or directory

### 問題原因

### 因為本人使用的是docker容器安裝的docker

### 解決方案---我沒有解決了,可能還需要將cmd或者entrypoint設定為/usr/sbin/init

### 啟動時設定引數 --privileged

### 使用該引數,container內的root擁有真正的root許可權

### 否則,container內的root只是外部的乙個普通使用者許可權。

### docker run --privileged=true -it --name centosssh centos:7 /bin/bash

### docker run --privileged -d -p 30001:12007 -p 31001:22 --name jedi-smq hfq/jedi:v6

#從映象倉庫中拉去hello-world映象

#執行hello-world images

#輸出的內容

hello from docker!

to generate this message, docker took the following steps:

1. the docker client contacted the docker daemon.

2. the docker daemon pulled the

"hello-world" image from

the docker hub.

3. the docker daemon created a

new container from that image which runs the

executable that produces the output you are currently reading.

4. the docker daemon streamed that output to

the docker client, which sent it

to your terminal.

to try something more ambitious, you can run an ubuntu container with:

$ docker run -it ubuntu bash

share images, automate workflows, and more with

a free docker id:

for more examples and ideas, visit:

root@5a25c7e57895:~#

##從映象倉庫中拉去image映象

##檢視當前有的image映象

##啟動乙個映象

##docker run 常用命令引數

-it 互動式

--name 給container起名字

-d 後台啟動

-p 埠

-p 大寫p,隨機埠

-v 磁碟對映

eg: docker run -it -p 8080

:80 -v /local/dir:/docker/container/dir ubuntu:

16.04 /bin/bash

##檢視container狀態

##其他##

#刪除container

rm #刪除image

docker rmi #修改tag名稱

docker tag old-image[:old-tag] new-image[:new-tag]

#退出後台執行:在互動式情況下執行

ctrl + p ;ctrl + q

#批量刪除container,其中"***/jedi:v5"是過濾內容項

docker rm $(docker ps -a | grep "***/jedi:v5" | awk '')

from

#基礎映象**

maintainer #作者

add && copy #拷貝物理機檔案到docker容器中

run #配置image環境的軟體等

env #配置環境變數

expose #暴露埠

volume #掛載磁碟

entrypoint && cmd #容器啟動的時候執行的命令

dockerfile樣例:

## -t 表示tag .代表dockerfile中的相對路徑,絕對路徑需要加 -f

docker build -t my/ubuntu:14.04 .

1、add 或 copy 不能到容器中的/root中

2、entrypoint 和 cmd 不同

docker技術分享

docker可以看成是乙個檔案系統,他提供了除核心外的完整的執行時的環境。也就是說在這個檔案系統裡,可以包含部署的應用程式。這樣做的好處是提高了工程的遷移性,提高同時也保證了對線上環境更好的控制,而且比起虛擬機器技術,docker可以獲得更好的效能,但是他的隔離性要稍微差一些。有關概念 映象,容器,...

《Docker的使用》 二 Docker基本使用

1 建立並執行乙個互動式容器 docker run name my ubuntu it ubuntu bin bash name 指定乙個容器名字,如果不加 name則由docker隨機分配乙個容器名字 合法名字只能包含 大小寫字母,數字,下劃線,圓點,橫線 i t i 保持標準輸入的開啟 t 給容...

JEECG使用分享

公司一直使用自己開發的框架,許可權,流程基本的功能都實現了,自動生成,只需要寫邏輯,工作很輕鬆,心裡卻一直很不幹。眼看著開源框架的大力流行,一直想著能把幾大流行又好用的開源框架結合起來又能最大限度減低工作量。於是先是學習各流行的開源框架,後來找到了easyjweb,使用了一段時間,卻因為此框架的更新...