Category Archives: Container

19. DevOps:How to upload your docker image to your dockerhub account ?

Docker-logo

How to upload your docker image to your dockerhub account from Ubuntu  ?

In my previous session, we have created the MySQL docker image.

Now let us assume, we need to move into a private registry of dockerhub to save it.

In this exercise we will see:
1. How to use dockerid and tag the image ?
2. How to list the images with dockerid ?
3. How to login to dockerhub with your id ?
4. How to upload your docker image to your docker account and registry ?

Pre-requisites: You need to have your dockerid from https://hub.docker.com/

======>Current mysql images====>
vskumar@ubuntu:~$ sudo docker image ls mysql*
[sudo] password for vskumar:
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 5d4d51c57ea8 5 weeks ago 374MB
vskumar@ubuntu:~$
==================>

1. How to use dockerid and tag the image ?

My docker id is: vskumardocker
== Using docker id into local variable====>
vskumar@ubuntu:~$
vskumar@ubuntu:~$ export DOCKERID=vskumardocker
vskumar@ubuntu:~$ echo $DOCKERID
vskumardocker
vskumar@ubuntu:~$
==================>

= Tagging with dockerid ====>
vskumar@ubuntu:~$ sudo docker image build –tag $DOCKERID/mysql .
ERRO[0301] Can’t add file /home/vskumar/.gnupg/S.gpg-agent to tar: archive/tar: sockets not supported
ERRO[0324] Can’t add file /home/vskumar/.local/share/ubuntu-amazon-default/ubuntu-amazon-default/SingletonSocket to tar: archive/tar: sockets not supported
Sending build context to Docker daemon 808MB
Step 1/2 : FROM mysql
—> 5d4d51c57ea8
Step 2/2 : CMD [“echo”, “This is Mysql done by vskumar for a lab practice of dockerfile”]
—> Using cache
—> 659477c48f0a
Successfully built 659477c48f0a
Successfully tagged vskumardocker/mysql:latest
vskumar@ubuntu:~$
== Tagged mysql image =======>

=== Let us check it ===>
vskumar@ubuntu:~$ sudo docker image ls |more
REPOSITORY TAG IMAGE ID CREATED SIZE
vskumardocker/mysql latest 659477c48f0a 4 weeks ago 374MB
mysql latest 5d4d51c57ea8 5 weeks ago 374MB
== Newly tagged image is there ====>

2. How to list the images with dockerid ?

You can also list the images with dockerid assigned as below:

= How to list the images with dockerid? ====>
vskumar@ubuntu:~$ sudo docker image ls -f reference=”$DOCKERID/*”
REPOSITORY TAG IMAGE ID CREATED SIZE
vskumardocker/mysql latest 659477c48f0a 4 weeks ago 374MB
vskumar@ubuntu:~$
=======>

3. How to login to dockerhub with your id ?

=== Login to dockerhub====>
vskumar@ubuntu:~$ sudo docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don’t have a Docker ID, head over to https://hub.docker.com to create one.
Username: vskumardocker
Password:
Login Succeeded
vskumar@ubuntu:~$
============>

4. How to upload your docker image to your docker account and registry ?

Now, let us use docker push command to push the image to dockerhub:

=== Pushing the image to dockerhub account registry ===>
vskumar@ubuntu:~$ sudo docker image push $DOCKERID/mysql:latest
The push refers to repository [docker.io/vskumardocker/mysql]
12ea28f10d69: Mounted from library/mysql
400836ab4664: Mounted from library/mysql
17d36ba94219: Mounted from library/mysql
d7758e0ab2b0: Mounted from library/mysql
921bf5c178ac: Mounted from library/mysql
3cf1630a511d: Mounted from library/mysql
b80c494a1fdc: Mounted from library/mysql
7b2001677ac9: Mounted from library/mysql
8b452d78b126: Mounted from library/mysql
292c1ee413d0: Mounted from library/mysql
014cf8bfcb2d: Mounted from library/mysql
latest: digest: sha256:09ebaab0035b1955a83646ea41f43a2cd870c934a2255da090918ff7ad37dd0f size: 2621
vskumar@ubuntu:~$
==Note, repository name, TAG should be there correctly ===>

Now, we can see this image on the web page of the docker account:
===== pushed Image onto dockerhub web page ====>
I found the image on the web page with the below name:
vskumardocker/mysql
public
=====================>

 

 

 

Protected: 20. DevOps:How to Install docker for Windows 10 and use for containers creation ?

This content is password protected. To view it please enter your password below:

2. Graph database/Docker: How to install Neo4j on a docker container? [for Ubuntu 18.04 VM]

Neo4j                                                                                                      Docker-logo

I have shown in this blog/video on the “Installing Neo4j DB on a Docker container using Ubuntu 18.04 VM”.

Through this blog and video, I have demonstrated the below functions:

a) How to install docker on an Ubuntu 18.04 VM?

b) How to create the Neo4j container from the image ?

c) How to use the container for neo4j browser ?

d) How to login and operate the options ?

c) Then how to shutdown the neo4j container ?

On all the above steps, a practiced video is made for your lab practice.

This is attached at the end of this blog.

Step1:
Initially, we need to check whether the prerequisite packages are installed.
To check, perform the following:

sudo apt-get -y install apt-transport-https ca-certificates curl

Step2:
Then, add the docker.com keys to our local keyset:

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –

Step3:
Next, Add the Docker repository to our system (Ubuntu users, I am assuming you have a 64-bit CPU in your VM):

sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

Step4:
Now, we need to work on Preparing the filesystem.
As we planned want need to keep track of the logs and be able to reuse our data, we will need to give the
Docker image some access to our filesystem.
In our home folder [~], let’s create a Neo4j folder and two subfolders named logs and data.
This below script will do it on a Linux platform:
cd ~
mkdir neo4j
cd neo4j
mkdir logs
mkdir data

Enter the above steps in a .sh script.

Step5:
How to Run Neo4j in a Docker container ?:
I need to run the below command;

sudo apt install docker.io

Now, we can run the below long command in a Terminal to run Docker with a Neo4j image.

sudo docker run –rm –publish=7474:7474 –publish=7687:7687 –volume=$HOME/neo4j/data:/data \
–volume=$HOME/neo4j/logs:/logs neo4j:3.1.2

This command triggered some downloading because our local Docker repository does not have the
Neo4j image available in its 3.1.2 version yet.

Ports used by Neo4j are 7474, 7473, and 7687, for the protocols http, https, and bolt, respectively .
In the parameters part, you can see–volume twice.
Its use is to link the folder on the local filesystem to the container filesystem.

Step6:
Providing the port numbers given as parameters were not in use,
the Terminal should display something like this:

Remote interface available at : http://localhost:7474

Now, it denotes our Docker container started for Neo4j.

This informs us that Neo4j is expecting us to connect on port 7474 as usual.
So let us fire our browser and browse to the very same
URL we saw earlier, http://localhost:7474, and go graphing!
(Make sure our data will be persisted on disk.)

Step7:
now, How to stop Docker running your image ?

In order to stop Docker , you need to pass not the name (of the image)
but the identifier of the running container (based on the image).

So, in another Terminal, let us type as follows to know the status of containers:
docker ps

This will list all the containers running, in our case, only one.
So we look at the first column, container_id, and use it as a parameter:
docker stop container_id

You can watch the terminal screen.
Docker container stopped as it should be stopped with this command.

For typical installation procedure of neo4j visit my blog:

https://vskumar.blog/2017/12/08/how-to-install-neo4j-3-2-6-graph-database-on-ubuntu/

 

 

Vcard-Shanthi Kumar V-v3

Advt-course3rd page

18. DevOps: How to create a MySQL docker container ?

Docker-logo

MySql DB docker container:

In this blog I would like to demonstrate the container creation for MYSQL DB.

The following dockerfile code can be used to create the mysqldb container:
I have made this as  group of commands to be executed from Ubuntu CLI.
=== Dockerfile code for MySql DB=====>
sudo docker container run \
–detach \
–name mysqldb \
-e MYSQL_ROOT_PASSWORD=my-secret-pw \
mysql:latest
=== To create mysqldb container ====>

=== Screen output ====>
vskumar@ubuntu:~$
vskumar@ubuntu:~$ sudo docker container run \
> –detach \
> –name mysqldb \
> -e MYSQL_ROOT_PASSWORD=my-secret-pw \
> mysql:latest
dcfc16b7fba9075c59035e29a0efed91b7872e5f5cf72c8656afade824651041
vskumar@ubuntu:~$
==== Created mysql =====>

Please note this time, I have not copied the complete display contents.

=== listed ====>
vskumar@ubuntu:~$ sudo docker image ls mysql
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 5d4d51c57ea8 5 weeks ago 374MB
vskumar@ubuntu:~$

vskumar@ubuntu:~$ sudo docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dcfc16b7fba9 mysql:latest “docker-entrypoint.s…” 3 minutes ago Up 3 minutes 3306/tcp mysqldb
a5f1ce30c02d swarm “/swarm manage” 11 days ago Restarting (1) 28 seconds ago gracious_bhabha
vskumar@ubuntu:~$
=================>

So we can have the mysql container also running in background currently.

Let us understand the commands/options used for dockerfile syntax:

Using ‘–detach’ command it runs the container in background.
I have given the container name ‘mysqldb’ with ‘–name’ option.
MySql DB needs the root password.
It has been executed with ‘-e’ option.
Since the mysql db image is not available in my current images list,
it pulls it from dockerhub.

You can try to use the same container for your db usage.