File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -600,6 +600,26 @@ docker.command('login -u myusername -p mypassword').then(function (data) {
600600// Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password
601601```
602602
603+ * docker pull
604+
605+ ``` js
606+ docker .command (' pull nginx:latest' ).then (function (data ) {
607+ console .log (' data = ' , data);
608+ // Successfully pulled image
609+ }, function (rejected ) {
610+ console .log (' rejected = ' , rejected);
611+ // Failed to pull image
612+ });
613+
614+ // data = { command: 'docker pull nginx:1.15.2 ',
615+ // raw:'1.15.2: Pulling from library/nginx\nDigest: sha256:d85914d547a6c92faa39ce7058bd7529baacab7e0cd4255442b04577c4d1f424\nStatus: Image is up to date for nginx:1.15.2\n',
616+ // login: '1.15.2: Pulling from library/nginx\nDigest: sha256:d85914d547a6c92faa39ce7058bd7529baacab7e0cd4255442b04577c4d1f424\nStatus: Image is up to date for nginx:1.15.2' }
617+
618+ // rejected = error: 'Error: Command failed: docker pull nginx:999.999.999
619+ // Error response from daemon: manifest for nginx:999.999.999 not found
620+ // ' stdout = '' stderr = 'Error response from daemon: manifest for nginx:999.999.999 not found
621+ ```
622+
603623
604624## License
605625
Original file line number Diff line number Diff line change @@ -132,4 +132,37 @@ test("docker-cli-js", (t) => {
132132 } ) ;
133133 } ) ;
134134
135+ t . test ( "pull latest" , ( t ) => {
136+
137+ const docker = new Docker ( ) ;
138+
139+ return docker . command ( "pull nginx" ) . then ( function ( data ) {
140+ console . log ( "data = " , data ) ;
141+ t . ok ( data . login ) ;
142+ } ) ;
143+ } ) ;
144+
145+ t . test ( "pull specific tag" , ( t ) => {
146+
147+ const docker = new Docker ( ) ;
148+
149+ return docker . command ( "pull nginx:1.15.2" ) . then ( function ( data ) {
150+ console . log ( "data = " , data ) ;
151+ t . ok ( data . login ) ;
152+ } ) ;
153+ } ) ;
154+
155+ t . test ( "pull intentionally failed, invalid image" , ( t ) => {
156+
157+ const docker = new Docker ( ) ;
158+
159+ return docker . command ( "pull nginx:999.999.999" ) . then ( function ( data ) {
160+ console . log ( "data = " , data ) ;
161+ t . notOk ( data . login ) ;
162+ } , function ( rejected ) {
163+ console . log ( "rejected = " , rejected ) ;
164+ t . ok ( / e r r o r / . test ( rejected ) ) ;
165+ } ) ;
166+ } ) ;
167+
135168} ) ;
Original file line number Diff line number Diff line change @@ -130,6 +130,14 @@ const extractResult = function(result: any) {
130130 run ( resultp : any ) {
131131 resultp . login = resultp . raw . trim ( ) ;
132132
133+ return resultp ;
134+ } ,
135+ } ,
136+ {
137+ re : / p u l l / ,
138+ run ( resultp : any ) {
139+ resultp . login = resultp . raw . trim ( ) ;
140+
133141 return resultp ;
134142 } ,
135143 } ,
You can’t perform that action at this time.
0 commit comments