markdown 生成批量`docker pull`命令
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 生成批量`docker pull`命令相关的知识,希望对你有一定的参考价值。
require 'json'
file = File.read('images.json')
images = JSON.parse(file)
images.each do |i|
puts "docker pull #{i["Repository"]}:#{i["Tag"]}"
end
[
{
"Containers":"N/A",
"CreatedAt":"2018-04-30 13:55:45 +0000 UTC",
"CreatedSince":"4 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"ae513a47849c",
"Repository":"nginx",
"SharedSize":"N/A",
"Size":"109MB",
"Tag":"latest",
"UniqueSize":"N/A",
"VirtualSize":"109MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-20 08:47:18 +0000 UTC",
"CreatedSince":"5 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"0164c13b662c",
"Repository":"mysql",
"SharedSize":"N/A",
"Size":"372MB",
"Tag":"5.7.22",
"UniqueSize":"N/A",
"VirtualSize":"371.9MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-20 08:35:37 +0000 UTC",
"CreatedSince":"5 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"8d65ec712c69",
"Repository":"mysql",
"SharedSize":"N/A",
"Size":"445MB",
"Tag":"latest",
"UniqueSize":"N/A",
"VirtualSize":"444.7MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-20 05:48:13 +0000 UTC",
"CreatedSince":"5 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"761aaf7a6ed6",
"Repository":"abiosoft/caddy",
"SharedSize":"N/A",
"Size":"44.5MB",
"Tag":"latest",
"UniqueSize":"N/A",
"VirtualSize":"44.48MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-19 21:10:06 +0000 UTC",
"CreatedSince":"5 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"f0b6a295092e",
"Repository":"mariadb",
"SharedSize":"N/A",
"Size":"403MB",
"Tag":"10.3.6",
"UniqueSize":"N/A",
"VirtualSize":"402.6MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-19 07:59:07 +0000 UTC",
"CreatedSince":"5 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"9ad43154c9b7",
"Repository":"abiosoft/caddy",
"SharedSize":"N/A",
"Size":"44.5MB",
"Tag":"0.10.13",
"UniqueSize":"N/A",
"VirtualSize":"44.48MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-12 18:58:27 +0000 UTC",
"CreatedSince":"6 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"c9d990395902",
"Repository":"ubuntu",
"SharedSize":"N/A",
"Size":"113MB",
"Tag":"16.04",
"UniqueSize":"N/A",
"VirtualSize":"112.9MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-12 18:39:03 +0000 UTC",
"CreatedSince":"6 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"3b853789146f",
"Repository":"ubuntu",
"SharedSize":"N/A",
"Size":"223MB",
"Tag":"14.04",
"UniqueSize":"N/A",
"VirtualSize":"222.8MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-10 18:20:30 +0000 UTC",
"CreatedSince":"6 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"b175e7467d66",
"Repository":"nginx",
"SharedSize":"N/A",
"Size":"109MB",
"Tag":"1.13.12",
"UniqueSize":"N/A",
"VirtualSize":"108.9MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-10 11:04:11 +0000 UTC",
"CreatedSince":"7 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"0dd91964be1d",
"Repository":"zulhfreelancer/node-ffmpeg",
"SharedSize":"N/A",
"Size":"210MB",
"Tag":"latest",
"UniqueSize":"N/A",
"VirtualSize":"210.3MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-10 05:16:37 +0000 UTC",
"CreatedSince":"7 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"96a7935aa0dd",
"Repository":"wordpress",
"SharedSize":"N/A",
"Size":"402MB",
"Tag":"fpm",
"UniqueSize":"N/A",
"VirtualSize":"401.5MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-10 05:16:12 +0000 UTC",
"CreatedSince":"7 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"e0fdcac0034b",
"Repository":"wordpress",
"SharedSize":"N/A",
"Size":"442MB",
"Tag":"4.9.5-php7.2-apache",
"UniqueSize":"N/A",
"VirtualSize":"441.9MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-06 18:18:30 +0000 UTC",
"CreatedSince":"7 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"aa3e171e4e95",
"Repository":"node",
"SharedSize":"N/A",
"Size":"673MB",
"Tag":"9.11.1",
"UniqueSize":"N/A",
"VirtualSize":"672.9MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-04-04 23:50:33 +0000 UTC",
"CreatedSince":"7 weeks ago",
"Digest":"\u003cnone\u003e",
"ID":"0666f15a5ae1",
"Repository":"php",
"SharedSize":"N/A",
"Size":"357MB",
"Tag":"7.2.4",
"UniqueSize":"N/A",
"VirtualSize":"357MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-03-29 16:55:06 +0000 UTC",
"CreatedSince":"2 months ago",
"Digest":"\u003cnone\u003e",
"ID":"1624ebb80e3e",
"Repository":"ruby",
"SharedSize":"N/A",
"Size":"863MB",
"Tag":"2.5.1",
"UniqueSize":"N/A",
"VirtualSize":"862.9MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-03-22 21:10:32 +0000 UTC",
"CreatedSince":"2 months ago",
"Digest":"\u003cnone\u003e",
"ID":"805130e51ae9",
"Repository":"httpd",
"SharedSize":"N/A",
"Size":"178MB",
"Tag":"2.4.33",
"UniqueSize":"N/A",
"VirtualSize":"177.5MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-03-22 07:06:47 +0000 UTC",
"CreatedSince":"2 months ago",
"Digest":"\u003cnone\u003e",
"ID":"33d02cfcfeab",
"Repository":"zulhfreelancer/mew_docker",
"SharedSize":"N/A",
"Size":"80.3MB",
"Tag":"latest",
"UniqueSize":"N/A",
"VirtualSize":"80.34MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-03-14 19:09:05 +0000 UTC",
"CreatedSince":"2 months ago",
"Digest":"\u003cnone\u003e",
"ID":"b05c3d76c8b3",
"Repository":"redis",
"SharedSize":"N/A",
"Size":"99.7MB",
"Tag":"3.2.11",
"UniqueSize":"N/A",
"VirtualSize":"99.71MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-03-14 16:53:49 +0000 UTC",
"CreatedSince":"2 months ago",
"Digest":"\u003cnone\u003e",
"ID":"30121e967865",
"Repository":"postgres",
"SharedSize":"N/A",
"Size":"289MB",
"Tag":"10.3",
"UniqueSize":"N/A",
"VirtualSize":"288.5MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-03-14 07:46:15 +0000 UTC",
"CreatedSince":"2 months ago",
"Digest":"\u003cnone\u003e",
"ID":"96dd4fed4359",
"Repository":"mysql",
"SharedSize":"N/A",
"Size":"291MB",
"Tag":"8.0.4",
"UniqueSize":"N/A",
"VirtualSize":"291.3MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-01-22 13:16:08 +0000 UTC",
"CreatedSince":"4 months ago",
"Digest":"\u003cnone\u003e",
"ID":"36f1cfe38369",
"Repository":"zulhfreelancer/ethereum_explorer",
"SharedSize":"N/A",
"Size":"644MB",
"Tag":"latest",
"UniqueSize":"N/A",
"VirtualSize":"643.6MB"
},
{
"Containers":"N/A",
"CreatedAt":"2018-01-12 13:36:57 +0000 UTC",
"CreatedSince":"4 months ago",
"Digest":"\u003cnone\u003e",
"ID":"aeea42b2dc85",
"Repository":"zulhfreelancer/ffmpeg_thumb",
"SharedSize":"N/A",
"Size":"523MB",
"Tag":"latest",
"UniqueSize":"N/A",
"VirtualSize":"523.5MB"
},
{
"Containers":"N/A",
"CreatedAt":"2017-09-26 10:44:53 +0000 UTC",
"CreatedSince":"8 months ago",
"Digest":"\u003cnone\u003e",
"ID":"e07ac1b7b0c9",
"Repository":"zulhfreelancer/ruby_rvm",
"SharedSize":"N/A",
"Size":"435MB",
"Tag":"2.4.1",
"UniqueSize":"N/A",
"VirtualSize":"434.5MB"
},
{
"Containers":"N/A",
"CreatedAt":"2017-09-14 10:16:43 +0000 UTC",
"CreatedSince":"8 months ago",
"Digest":"\u003cnone\u003e",
"ID":"c856fe03af21",
"Repository":"zulhfreelancer/ruby_nodejs",
"SharedSize":"N/A",
"Size":"753MB",
"Tag":"latest",
"UniqueSize":"N/A",
"VirtualSize":"753.3MB"
}
]
#### Steps
1. Run `docker images --format '{{ json . }}' | pbcopy`
2. Open text editor i.e. Atom
3. Add an empty array `[]`
4. Paste the content from step 1 into the empty array
5. At the end of each hash `{}`, add a comma `,` - except the last object
6. Go to [JSON Formatter site](https://jsonformatter.curiousconcept.com/)
7. Paste into the box, hit the Process button and save the output file name as `images.json`
8. Make sure both `images.json` and `images.rb` are in the same directory
9. Run the `images.rb` file: `$ ruby images.rb`
#### Example
```
$ ruby images.rb
docker pull nginx:latest
docker pull mysql:5.7.22
docker pull mysql:latest
docker pull abiosoft/caddy:latest
docker pull mariadb:10.3.6
docker pull abiosoft/caddy:0.10.13
docker pull ubuntu:16.04
docker pull ubuntu:14.04
docker pull nginx:1.13.12
docker pull zulhfreelancer/node-ffmpeg:latest
docker pull wordpress:fpm
docker pull wordpress:4.9.5-php7.2-apache
docker pull node:9.11.1
docker pull php:7.2.4
docker pull ruby:2.5.1
docker pull httpd:2.4.33
docker pull zulhfreelancer/mew_docker:latest
docker pull redis:3.2.11
docker pull postgres:10.3
docker pull mysql:8.0.4
docker pull zulhfreelancer/ethereum_explorer:latest
docker pull zulhfreelancer/ffmpeg_thumb:latest
docker pull zulhfreelancer/ruby_rvm:2.4.1
docker pull zulhfreelancer/ruby_nodejs:latest
```
以上是关于markdown 生成批量`docker pull`命令的主要内容,如果未能解决你的问题,请参考以下文章