I decided to give the IBM Containers service a quick test drive today. I used this very simple example available at the following GitHub URL
https://github.com/Samze/ibm-containers-simple-node-example
1. Clone the source code as follows
pas@192-168-1-4:~/temp$ git clone https://github.com/Samze/ibm-containers-simple-node-example
Cloning into 'ibm-containers-simple-node-example'...
remote: Counting objects: 63, done.
remote: Total 63 (delta 0), reused 0 (delta 0), pack-reused 63
Unpacking objects: 100% (63/63), done.
Checking connectivity... done.
2. Build as shown below.
pas@Pass-MacBook-Pro:~/bluemix-apps/CONTAINERS/ibm-containers-simple-node-example$ docker build -t simplenode:latest .
Sending build context to Docker daemon 921.6 kB
Sending build context to Docker daemon
Step 0 : FROM registry-ice.ng.bluemix.net/ibmnode:latest
---> e9991fa102c2
Step 1 : ADD . /node
---> e06d64586fcb
Removing intermediate container 115a1f348c9c
Step 2 : WORKDIR /node
---> Running in bbbbb3e2044c
---> 341de1dca2a2
Removing intermediate container bbbbb3e2044c
Step 3 : RUN npm install
---> Running in c5157b73d74a
npm WARN package.json ibm-containers-simple-node-example@0.0.0 No repository field.
npm ERR! fetch failed https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/escape-html/-/escape-html-1.0.1.tgz
npm ERR! fetch failed https://registry.npmjs.org/on-finished/-/on-finished-2.2.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.3.tgz
npm ERR! fetch failed https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.0.7.tgz
npm ERR! fetch failed https://registry.npmjs.org/crc/-/crc-3.2.1.tgz
npm ERR! fetch failed https://registry.npmjs.org/destroy/-/destroy-1.0.3.tgz
npm ERR! fetch failed https://registry.npmjs.org/crc/-/crc-3.2.1.tgz
npm ERR! fetch failed https://registry.npmjs.org/mime-db/-/mime-db-1.8.0.tgz
ejs@2.3.1 node_modules/ejs
express@4.12.3 node_modules/express
├── merge-descriptors@1.0.0
├── utils-merge@1.0.0
├── cookie-signature@1.0.6
├── methods@1.1.1
├── cookie@0.1.2
├── fresh@0.2.4
├── escape-html@1.0.1
├── range-parser@1.0.2
├── finalhandler@0.3.4
├── content-type@1.0.1
├── vary@1.0.0
├── parseurl@1.3.0
├── serve-static@1.9.2
├── content-disposition@0.5.0
├── path-to-regexp@0.1.3
├── depd@1.0.1
├── qs@2.4.1
├── proxy-addr@1.0.7 (forwarded@0.1.0, ipaddr.js@0.1.9)
├── debug@2.1.3 (ms@0.7.0)
├── send@0.12.2 (destroy@1.0.3, ms@0.7.0, mime@1.3.4)
├── type-is@1.6.1 (media-typer@0.3.0, mime-types@2.0.10)
├── etag@1.5.1 (crc@3.2.1)
├── on-finished@2.2.0 (ee-first@1.1.0)
└── accepts@1.2.5 (negotiator@0.5.1, mime-types@2.0.10)
---> 6a8303faa142
Removing intermediate container c5157b73d74a
Step 4 : EXPOSE 8080
---> Running in 2ef2338c54f0
---> 92fcbb0123ac
Removing intermediate container 2ef2338c54f0
Step 5 : ENTRYPOINT node /node/index.js
---> Running in 9abbc0dd1b10
---> 0c09d70174b1
Removing intermediate container 9abbc0dd1b10
Successfully built 0c09d70174b1
3. Log into IBM Containers
pas@Pass-MacBook-Pro:~/bluemix-apps/CONTAINERS$ ice login
API endpoint: https://api.ng.bluemix.net
Email> pasapi@au1.ibm.com
Password>
Authenticating...
OK
Targeted org pasapi@au1.ibm.com
Select a space (or press enter to skip):
1. dev
2. apple
3. lemon
4. pas
Space> 1
Targeted space dev
API endpoint: https://api.ng.bluemix.net (API version: 2.19.0)
User: pasapi@au1.ibm.com
Org: pasapi@au1.ibm.com
Space: dev
Authentication with container cloud service at https://api-ice.ng.bluemix.net/v2.0/containers completed successfully
You can issue commands now to the container service
Proceeding to authenticate with the container cloud registry at registry-ice.ng.bluemix.net
Login Succeeded
4. Retrieve your current namespace
pas@Pass-MacBook-Pro:~/bluemix-apps/CONTAINERS$ ice namespace get
apples01
5. Tag the image to point to your private registry.
pas@Pass-MacBook-Pro:~/bluemix-apps/CONTAINERS/ibm-containers-simple-node-example$ ice --local tag -f simplenode:latest registry-ice.ng.bluemix.net/apples01/simplenode:latest
Target is local host. Invoking docker with the given arguments...
6. Push the image to your private registry.
pas@Pass-MacBook-Pro:~/bluemix-apps/CONTAINERS/ibm-containers-simple-node-example$ ice --local push registry-ice.ng.bluemix.net/apples01/simplenode:latest
Target is local host. Invoking docker with the given arguments...
The push refers to a repository [registry-ice.ng.bluemix.net/apples01/simplenode] (len: 1)
Sending image list
Pushing repository registry-ice.ng.bluemix.net/apples01/simplenode (1 tags)
Image 511136ea3c5a already pushed, skipping
Image a1a958a24818 already pushed, skipping
Image d0955f21bf24 already pushed, skipping
Image 9fec74352904 already pushed, skipping
Image a3d3e588211d already pushed, skipping
Image 19a35b496c0d already pushed, skipping
Image 1adb38c035f4 already pushed, skipping
Image f3c84ac3a053 already pushed, skipping
Image bf94729cc072 already pushed, skipping
Image cbc052ac72f1 already pushed, skipping
Image 12433edaed33 already pushed, skipping
Image c4a2c78444b7 already pushed, skipping
Image 300247e5330a already pushed, skipping
Image e9991fa102c2 already pushed, skipping
e06d64586fcb: Image successfully pushed
341de1dca2a2: Image successfully pushed
6a8303faa142: Image successfully pushed
92fcbb0123ac: Image successfully pushed
0c09d70174b1: Image successfully pushed
Pushing tag for rev [0c09d70174b1] on {https://registry-ice.ng.bluemix.net/v1/repositories/apples01/simplenode/tags/latest}
7. Start a new container in IBM Containers from the image you just pushed.
pas@Pass-MacBook-Pro:~/bluemix-apps/CONTAINERS/ibm-containers-simple-node-example$ ice run --name simplenode_1 -p 8080 apples01/simplenode:latest
2261936e-4324-4f28-b800-10099471a306
8. Verify it's up and running
pas@Pass-MacBook-Pro:~/bluemix-apps/CONTAINERS/ibm-containers-simple-node-example$ ice ps
Container Id Name Group Image Created State Private IP Public IP Ports
2261936e-4324-4f28-b800-10099471a306 simplenode_1 apples01/simplenode:latest Apr 10 23:13 Running 172.17.200.2 [8080]
9. The following commands assign a public IP address to my container
pas@Pass-MacBook-Pro:~/bluemix-apps/CONTAINERS/ibm-containers-simple-node-example$ ice ip list
Number of addresses: 0
pas@Pass-MacBook-Pro:~/bluemix-apps/CONTAINERS/ibm-containers-simple-node-example$ ice ip request
Successfully obtained ip: "129.41.233.119"
pas@Pass-MacBook-Pro:~/bluemix-apps/CONTAINERS/ibm-containers-simple-node-example$ ice ip list
Number of addresses: 1
Ip Address
129.41.233.119
pas@Pass-MacBook-Pro:~/bluemix-apps/CONTAINERS/ibm-containers-simple-node-example$ ice ip bind 129.41.233.119 simplenode_1
Successfully bound ip
10. Access the container as shown below.
http://129.41.233.119:8080/
More Information
https://www.ng.bluemix.net/docs/#starters/index-gentopic3.html#containers
No comments:
Post a Comment