docker-compose命令

#1.docker-compose

Compose 是一款用于使用 Docker 定义和运行复杂应用的工具。借助 Compose,您可以在单个文件中 定义一个多容器应用,然后在一条命令中激增您的应用,该命令可以执行使此应用运行所需完成的全部操作。

也称为: docker-compose, fig

#2.命令
docker-compose build docker-compose build
docker-compose bundle Create a distributed application bundle from the Compose file.
docker-compose config Config validates and view the compose file.
docker-compose create Create creates containers for a service.
Docker Compose release notes Release notes for Docker Compose
docker-compose down docker-compose down
docker-compose events Receive real time events from containers.
docker-compose exec docker-compose exec
docker-compose help docker-compose help
docker-compose images Lists images used by the project.
docker-compose kill Forces running containers to stop.
docker-compose pause Pauses running containers for a service.
docker-compose port Prints the public port for a port binding.s
docker-compose ps Lists containers.
docker-compose pull Pulls service images.
docker-compose push Pushes service images.
docker-compose restart Restarts Docker Compose services.
docker-compose rm Removes stopped service containers.
docker-compose run Runs a one-off command on a service.
docker-compose scale Sets the number of containers to run for a service.
docker-compose start Starts existing containers for a service.
docker-compose stop Stops running containers without removing them.
docker-compose top Displays the running processes.
docker-compose unpause Unpauses paused containers for a service.
docker-compose up Builds, (re)creates, starts, and attaches to containers for a service.

docker笔记

#1.Install packages to allow apt to use a repository over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common

#2.Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

#3.Use the following command to set up the stable repository.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

#4.Update the apt package index.
sudo apt update

#5.Install the latest version of Docker CE
sudo apt install docker-ce

#6.Ensure that you have a supported version of Docker:
docker version

#7.Verify that Docker CE is installed correctly by running the hello-world image.
sudo docker run hello-world

#8.List the hello-world image that was downloaded to your machine:
docker image ls

#9.List the hello-world container (spawned by the image) which exits after displaying its message. If it were still running, you would not need the --all option:
docker container ls --all

#10.Search the Docker Hub for images
docker search <image>

#11.Start container
docker start <name>

#12.Attach container
docker attach <name>

#13.Commit image
docker commit -m="has update" -a="comet" ea4c82dcd15a comet/ubuntu:v2

#20.Other command
docker build -t friendlyhello . # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyhello # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyhello # Same thing, but in detached mode
docker container ls # List all running containers
docker container ls -a # List all containers, even those not running
docker container stop <hash> # Gracefully stop the specified container
docker container kill <hash> # Force shutdown of the specified container
docker container rm <hash> # Remove specified container from this machine
docker container rm $(docker container ls -a -q) # Remove all containers
docker image ls -a # List all images on this machine
docker image rm <image id> # Remove specified image from this machine
docker image rm $(docker image ls -a -q) # Remove all images from this machine
docker login # Log in this CLI session using your Docker credentials
docker tag <image> username/repository:tag # Tag <image> for upload to registry
docker push username/repository:tag # Upload tagged image to registry
docker run username/repository:tag # Run image from a registry

#21.Docker command
Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes

Reference from :https://docs.docker.com/get-started/

ipa下载的方法

不通过app store发布ipa的要求:

1、ipa的下载地址放到plist的文件中,链接指定plist(plist格式见下文)

2、plist的链接要求一定是https的,而且必须是公网ssl,自签名及免费的https不可用。

3、链接格式要求一定是符合苹果规范的,itms-services://?action=download-manifest&url=https://****/***.plist

plist格式

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>http://xxxxxxxxxxxxxxxxxxx/xxx.ipa</string>
</dict>
<dict>
<key>kind</key>
<string>full-size-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>http://xxxxxxxxxxxxxxxxxx.png</string>
</dict>
<dict>
<key>kind</key>
<string>display-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>http://xxxxxxxxxxxxxxxxxx.png</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.xxxx.demo</string>
<key>bundle-version</key>
<string>1.0.0</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>XXXX App download</string>
</dict>
</dict>
</array>
</dict>
</plist>

ansible笔记

以下为markdown格式:

# 客户端
# 1.准备工作
## 1.1安装openssh-server和python
`apt install openssh-server pytnon`

## 1.2允许root登录
修改 /etc/ssh/sshd_config 中 PermitRootLogin 的值为yes
默认值为 prohibit-password

## 1.3重启openssh服务
`systemctl restart ssh.service`

# 管理端
# 1安装及配置ansible
## 1.1生成密钥对
使用root登录后执行 ssh-keygen 生成密钥对

## 1.2对客户端加入公钥
`ssh-copy-id -i .ssh/id_rsa.pub root@192.168.13.71`

## 1.3安装ansible
`apt install ansible`

## 1.4配置ansible
编辑 /etc/ansible/ansible.cfg

# 2使用ansible命令
## 2.1配置inventory文件
编辑inventory文件hosts

/etc/ansible/hosts

[mysrv]

192.168.13.71

## 2.2执行命令
ping hosts文件中全部的主机,-o为输出结果为1行

`ansible all -m ping -o`

复制test.txt文件到客户端
文件模式600,所属用户为user1,所属组为user1group
可以用file模块替代copy模块

`ansible mysrv -m copy -a 'src=test.txt dest=~/test.txt mode=600 owner=user1 group=user1group' -o`

利用username的用户去对mysrv组中的电脑进行重启
参数-f 10为fork出10个子进程(每次执行10台电脑)

`ansible mysrv -a "/sbin/reboot" -u username --sudo --ask-sudo-pass -f 10`

使用user模块可以方便的创建账户,删除账户,或是管理现有的账户:

`ansible all -m user -a "name=foo password=<crypted password here>"`

`ansible all -m user -a "name=foo state=absent"`

利用apt安装nginx,需输入密码

`ansible one -m apt -a "name=nginx state=present" --sudo --ask-sudo-pass`

利用apt卸载nginx,需输入密码

`ansible one -m apt -a "name=nginx state=absent" --sudo --ask-sudo-pass`

# 3使用playbook
## 3.1检测语法
`ansible-playbook --syntax-check the.yml`

## 3.2测试运行
`ansible-playbook -C the.yml`

## 3.3创建用户的例子
createuser.yml

```
---
- hosts: one
vars:
username: "testuser"
user: root
tasks:
- name: create user
user: name="{{ username }}"
```
执行playbook
`ansible-playbook createuser.yml`

## 3.3安装nginx的例子
nginx.yml

```
---
- hosts: one
remote_user: root
tasks:
- name: ensure nginx is at the latest version
apt: name=nginx state=latest
- name: ensure nginx is running
service: name=nginx state=started
handlers:
- name: restart nginx
service: name=nginx state=restarted
```

## 3.4状态类型
安装软件:state={present|latest}

卸载软件:state={absent}

服务状态:state={started|stoped|restarted}