Miscellaneous Table of Content




Subscribe To Our Newsletter
You will receive our latest post and tutorial.
Thank you for subscribing!

required
required


Transfer Files from iPhone to Mac and from Mac to Iphone

Transfer files from iPhone to Mac

Use AirDrop

  • Make sure both your iPhone and your Mac are on the same wifi network.
  • You find and select files(images) on your phone that you want to transfer to your Mac.
  • Click on the option icon
  • You will see a pop-up and on that pop-up, you should see the name of your Mac as one of the options
  • Select your Mac and your files will download to your Mac

Use cable

  • Connect your iPhone to your Mac using a cable
  • Open up the Image Capture(for images)
  • Select all images and videos you want to transfer and import them.

Transfer files from Mac to iPhone

Use AirDrop

  • From your Mac, if you open up your AirDrop, you should be able to see your iPhone name as one of the devices on AirDrop.
  • Select and drop files you want to transfer and that is it.

August 25, 2019

Docker Guide

 

What is docker?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Building and deploying new applications is faster with containers. Docker containers wrap up your application and everything it needs such as dependencies and libraries into one package. This guarantees that your application will always run the same way regardless of the environments(Mac, Linux, Unix, Windows, etc). If the docker engine is installed on the environment your application will work. By doing this, you the developer can rest assured that your application will run on your local, Dev, QA, and production environment.

In a way, Docker is like a virtual machine. a virtual machine creates a whole virtual operating system, a docker container uses the same underlying operating system (Linux kernel) as the server that it is running on. Docker only requires applications to be shipped with things not already running on the host server. This gives a significant performance boost and reduces the size of the application.

What is Docker for?

Docker is designed to benefit both developers and system administrators, making it a part of many DevOps (developers + operations) toolchains. For developers, it means that they can focus on writing code without worrying about the system that it will ultimately be running on. It also allows them to get a head start by using one of the thousands of programs already designed to run in a Docker container as a part of their application. Things like MySQL, Redis Cache, and Messaging System(ActiveMQ) can be on their own containers and you run them together with your application.

Without docker containers, your application can behave differently in different environments. I have seen applications working on my local machine but not on my dev environment. One of the most frustrating things of deployment is when you have a working application on your local machine, but you deploy it to production and it does not work. Trust me I have seen this mess more than once. With Docker containers, you are confident that your applications will work on local, Dev, QA, and production.

Getting Started

Download docker and install it on your computer

  • Link to developer guide – https://docs.docker.com/ee/
  • Select the docker option based on your operation system. In my case, I selected Docker for desktop mac. Then from there should be a link to download the docker executable onto your computer.
  • You will have to create a docker account to download docker.
  • Install docker by double-clicking on the executable your downloaded and follow instructions.

Docker commands

You are going to use the command-line interface to work with Docker.

docker images
– list out all the images in your computer

docker ps -a
– list out all the running containers on your computer

docker rmi imageId
– delete or remove an image.

docker stop containerId
– stop a running container

docker rm containerId
– delete a container

docker pull image: tag
– pull an image from a docker registry(docker hub or AWS ECR).

docker pull mysql

 

Run docker container automatically

Use these tags 

-dit --restart unless-stopped

docker run -p outside-port:internal-port –name container-name -dit –restart unless-stopped -d image_name:image_tag
– run docker container with the port where the container will use both externally and internally, the name of the container, the image, and tag being used, and a command to make sure the container will restart if it stops.

– -d means that to run container in background and print container ID

docker run -p outside-port:internal-port --name container-name -dit --restart unless-stopped -d image_name:image_tag
docker run -p 8080:8080 --name springboot-hello-0-0-1 -dit --restart unless-stopped -d springboot-hello:0-0-1

 

Push up a docker image to aws docker registry

1. Login to aws ECR from your computer

aws ecr get-login-password --profile folauk110

2. Build image

docker build -t project .

3. Tag image

docker tag project:latest remote-ecr-url/project:latest

4. Push image to remote registry

docker push remote-ecr-url/project:latest

 

SSH into a docker container

docker exec -it {container-name} sh

or

docker exec -it {container-name} sh /bin/bash

 

Install Redis using docker

Pull redis docker image

docker pull redis

Run redis docker container

docker run --name container-redis -dit --restart unless-stopped -p 6379:6379 -d redis

Set keys and values in redis

First, ssh into the redis container.

docker exec -it container-redis sh

Second, use the redis-cli

redis-cli
127.0.0.1:6379> set docker great
OK
127.0.0.1:6379> get docker
"great"
127.0.0.1:6379> set name objectrocket
OK
127.0.0.1:6379> get name
"objectrocket"

 

Install Elasticsearch using docker

Pull elasticsearch docker image

Make sure to use the right version that your code and Kibana is using.

docker pull docker.elastic.co/elasticsearch/elasticsearch:7.1.0

Run elasticsearch docker container

docker run -p 9200:9200 -p 9300:9300 --name elasticsearch -e "discovery.type=single-node" -dit --restart unless-stopped -d docker.elastic.co/elasticsearch/elasticsearch:7.1.0

Install Kibana using docker

Pull kibana docker image

Make sure to use the right version that your code and elasticsearch is using.

docker pull docker.elastic.co/kibana/kibana:7.1.0

Run kibana docker container 

docker run --link elasticsearch:elasticsearch -dit --restart unless-stopped --name kibana -p 5601:5601 docker.elastic.co/kibana/kibana:7.1.0

Access kibana locally by going on http://localhost:5601/app/kibana

Postgresql with docker

#pull image
docker pull postgres:12.6
#run docker container
docker run --name postgres --restart unless-stopped -p 5432:5432 -e POSTGRES_PASSWORD=test -v /Users/folaukaveinga/Software/postgres/data:/var/lib/postgresql/data -d postgres:12.6

 

Ubuntu with docker

Sometimes when you want to play or learn linux you want to have a linux OS to play with. With docker you can pull a ubuntu docker image and run it locally.

docker pull ubuntu

Run a ubuntu container

docker run -it ubuntu /bin/bash

You will be in the root folder of the ubuntu container right away after running the above command.

Restart a docker container

docker container restart [OPTIONS] CONTAINER [CONTAINER...]

// -t or --time represents seconds to wait for stop before killing the container
docker container restart -t 5 bee0a80b1424

 

View logs of a docker container

docker logs [OPTIONS] CONTAINER

// Follow log output -f or --follow
docker logs -f asdfwers

 

 

August 20, 2019

Terminate process(PID) command

If you ever run multiple java projects (microservices) on eclipse. Most of the time you want to start them up all at the same time and luckily eclipse has this feature. Unfortunately what Eclipse doesn’t have is a way to stop or kill all of you java projects(processes) all at the same time. This is useful when you want fresh and clean instances for all my microservices and not have any process in a stale state.

To terminate all of your projects or java processes, do this:

  • Open up terminal and type in this command “killall java”
  • Or open terminal within your eclipse. Open Eclipse, right-click on a project in the Package Explorer panel, hover over Show in, select terminal, and type in this command “killall java”
August 20, 2019