Thursday, July 6, 2017

docker command simple summary

normal old local docker operator command:
$ docker create | stop | ps | rm

docker swarm machine operator command:
$ docker-machine create | stop | rm | ls

docker swarm operator command on machine:
$ docker swarm init | join-token | leave | join

docket network operator command on machine:
$ docket network ls | create | inspect | rm

single docker with docker-compose.yml or docker-compose.yaml:
$ docker-compose create | rm | start | stop | up

docker swarm with compose file:
$ docker stack deploy | ps | rm | services

docket swarm container service operator command in manager role of swarm machine:
$ docker service ls | create | rm | logs

docker list swarm node in manager role of swarm machine:
$ docker node ls

show consul run statist.(consul is service name)
$ docker service ps consul

$ docker exec -it $(docker ps | grep "pkrss-microsrv-consul" | awk {'print $1'}) ping consul-default

$ docker network inspect ingress

delete consul service:
$ docker service rm $(docker service ls | grep consul | awk '{print $1}')

create service on worker machine:
$ docker service create --name foo6 --constraint="node.role == worker" --network foo alpine sleep 999999

Last

docker swarm mode default by boot2docker method can not access ping each container service

docker swarm mode default by boot2docker method can not ping each container service

so before we create our swarm service, we need create our overlay network:
$ docker network create --driver overlay my-net

then create service with  parameter "--network my-net".
for example:
$ docker service create --replicas 1 --name consul --network my-net -p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -p 8600:8600 consul agent -server -bootstrap-expect 1 -ui -client 0.0.0.0 -advertise 192.168.3.132 -node=swarm1

Last:
Thanks!

Wednesday, July 5, 2017

com.spotify docker-maven-plugin used error and problem draft


My xml with:


 <properties>
        <docker.image.prefix>springio</docker.image.prefix>
        <docker.plugin.version>1.0.0</docker.plugin.version>
        <docker.repostory>192.168.3.131:5000</docker.repostory>
        <DOCKER_HOST>tcp://192.168.3.131:2376</DOCKER_HOST>
 </properties>

<build>      

       <plugins>

           <plugin>

               <groupId>org.springframework.boot</groupId>

               <artifactId>spring-boot-maven-plugin</artifactId>

               <executions>

                   <execution>

                       <goals>

                           <goal>repackage</goal>

                       </goals>

                   </execution>

               </executions>

           </plugin>

           <plugin>

               <groupId>com.spotify</groupId>

               <artifactId>docker-maven-plugin</artifactId>

               <version>${docker.plugin.version}</version>

              

               <configuration>

                   <imageName>${project.artifactId}</imageName>

                   <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>

                   <resources>

                       <resource>

                           <targetPath>/</targetPath>

                           <directory>${project.build.directory}</directory>

                           <include>${project.build.finalName}.jar</include>

                       </resource>

                   </resources>

               </configuration>

              

               <executions>

                 <execution>

          <id>build-image</id>

          <phase>package</phase>

          <goals>

            <goal>build</goal>

          </goals>

        </execution>

        <execution>

          <id>tag-image</id>

          <phase>package</phase>

          <goals>

            <goal>tag</goal>

          </goals>

                   <configuration>

                    <image>${project.artifactId}</image>

                     <newName>${docker.repostory}/${project.artifactId}</newName>

                   </configuration>

        </execution>

        <execution>

          <id>push-image</id>

          <phase>deploy</phase>

          <goals>

            <goal>push</goal>

          </goals>

          <configuration>

            <imageName>${docker.repostory}/${project.artifactId}</imageName>

          </configuration>

        </execution>

               </executions>

           </plugin>

       </plugins>

   </build>


Error:
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:tag (default-cli) on project pkrss-microsrv-consul:
 The parameters 'image', 'newName' for goal com.spotify:docker-maven-plugin:1.0.0:tag are missing or invalid -> [Help 1]

Why:
i used below command, and lost package.
$ mvn docker:tag -D pushImage


Error:
The push registry is docker.io not my self local registry responsity.
The push refers to a repository [docker.io/library/pkrss-microsrv-consul]


Why:
i used below command, and not have docker:build:
mvn package docker:tag -D pushImage

Suggest:

$ mvn clean package docker:build -D pushImageTags
clean command also can skip.
It is ok.

Last:
Thanks!

Tuesday, July 4, 2017

docker container images delete command summary

Docker container images delete command summary

1.show all docker container:
$ docker ps -a -q
stop all running container:
docker stop $(docker ps -a -q)
then you can delete all images:
$ docker rm $(docker ps -a -q)
2.show all images:
$ docker images
3.delete one image by id:
$ docker rmi <image id>
delete untagged images, which id is <None>:
$ docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
delete all images:
$ docker rmi $(docker images -q)
last
thanks!

2 docker machine add 2 consul instance

What
i run 2 docker machine , and want to instance each consul in each machine.

How

1. first machine is leader and it's ip is 192.168.3.131

docker run --restart=always -d -v /data:/data -p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -p 8600:8600 consul agent -server -bootstrap-expect 2 -ui -client 0.0.0.0 -advertise 192.168.3.131 -node=local


2. second machine is slave and it's ip is 192.168.3.132

docker run --restart=always -d -v /data:/data -p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -p 8600:8600 consul agent -server -ui -client 0.0.0.0 -advertise 192.168.3.132 -node=master1 -join 192.168.3.131



Other
> Error:  network may be misconfigured
> Error:  foreign ip cannot access http://192.168.3.131:8500/ui/
add
-p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -p 8600:8600


>