Thursday, September 20, 2018

Basic Docker Commands

Image is a class and container is an object of the class

To delete a container
docker ps -a //The command docker ps only displays running containers. To see all containers, including the stopped ones, use the -a parameter:
docker rm -f
docker system prune //clean up any resources — images, containers, volumes, and networks — that are dangling (not associated with a container):

How to see the log of a container
docker logs bcsandbox //every time the container starts is logs some important information like admin password etc

Get a list of images
docker images or docker image ls

Run an executeable on a docker image (test is the container)
docker exec -it cmd //it stands for interactive 

Spin a container from an image (or create an object from a class)
docker run [options] image[:tag] [command] [args]
docker run -e accept_eula=Y 53ee8b0703ad //53ee8b0703ad is the name of the image

-e stands for an environment variables

There are certain environment variables that used by Navision images
--hostname (-h) specifies the hostname of the container. This is the name you will use to connect to the containers web client and the name you can ping. If you do not specify the hostname, the first 12 characters of the container Id will be used as the hostname.
--name specifies the name of the container. The name is used when referring to the container with other docker commands. If the name is not specified, a random name will be generated using a verb and a name (like friendly_freddy)
--memory (-m) specifies the max. amount of memory the container can use. The default for this option depends on how you are running the container. When you run Windows Server Containers there are no implicit memory option and the container can basically use all memory available to the host. When you run HyperV containers, the default max. memory is 1Gb.
--volume (-v) specifies a folder from the host you want to share with the container and the path inside the container, where you want to mount this folder. --volume c:\myfolder:c:\run\my shares the existing c:\myfolder on the host to the container and the content is in c:\run\my.
--restart specifies the restart options for the container.

command :
docker run -e accept_eula=Y --name bcsandbox -h NAVBC -m 4G -e useSSL=N  -v c:\myfolder:c:\run\my --restart always -e exitonerror=N -e locale=en-us microsoft/bcsandbox

to start using my license file placed in c:\myfolder
docker run -e accept_eula=Y --name bcdev -h DEVBC -m 4G -e useSSL=N  -v c:\myfolder:c:\run\my -e licensefile=c:\run\my\alfazance.flf --restart always -e exitonerror=N -e locale=en-us microsoft/bcsandbox

Which will accept the eula and run the dynamics-nav:devpreview container with 4Gb of memory, test as the name and hostname, http (not https), restart option set to always, locale to en-US, and use the licensefile, which is located in c:\myfolder\license.flf on the host computer.

//Publishing the Docker images on the Network
1. Stop any running containers -> Docker stop bcsandbox
2. Stop the docker service -> Stop-Service Docker
3. Remove the current Containe network-> Get-ContainerNetwork | Remove-ContainerNetwork -Force
4. modify daemon.json file -> '{"bridge":"none"}' | Set-Content C:\ProgramData\docker\config\daemon.json
5. create transprent network (use of of the two commands) -> docker network create -d transparent tlan
New-ContainerNetwork -Name tlan -SubnetPrefix -GatewayAddress -Mode Transparent -DNSServers,
6. Start-Service Docker or restart the docker service
7. Run a container with the new adapter created ->
docker run --network tlan --ip --name devcontainer -e accept_eula=Y -h BCDEV -e username=admin -e password=pass@word1 -e useSSL=N  -v c:\myfolder:c:\run\my -e licensefile=c:\run\my\alfazance.flf --restart always -e exitonerror=N -e locale=en-us microsoft/bcsandbox

 Create an container using navcontainerhelper
new-navcontainer -accept_eula -includeCSide -containerName test -licenseFile c:\myfolder\alfazance.flf -imageName microsoft/dynamics-nav:devpreview
new-navcontainer -accept_eula -includeCSide -containerName test -licenseFile c:\myfolder\alfazance.flf -auth NavUserPassword -imageName microsoft/bcsandbox

commit container as a new image
docker commit navcontainer navbcuaeloc/ver1:lan adapter changed
docker run -d navbcuaeloc/ver1

Fixing the Error = HNS failed with error : Element not found.

stop-service hns
stop-service docker
del 'C:\ProgramData\Microsoft\Windows\hns\'
start-service hns
start-service docker

C:\myfolder\\CleanupContainerHostNetworking.ps1 -Cleanup -ForceDeleteAllSwitches
Restart-Computer -Force

docker run --network tlan --ip --name bcangshudev -e accept_eula=Y -h BCANGSHU -e username=admin -e password=pass@word1 -e useSSL=N  -v c:\myfolder:c:\run\my -e licensefile=c:\run\my\alfazance.flf --restart always -e exitonerror=N -e locale=en-us microsoft/bcsandbox
docker run --network tlan --ip --name bckirtidev -e accept_eula=Y -h BCKIRTI -e username=admin -e password=pass@word1 -e useSSL=N  -v c:\myfolder:c:\run\my -e licensefile=c:\run\my\alfazance.flf --restart always -e exitonerror=N -e locale=en-us microsoft/bcsandbox

New-NavContainer -containerName bcsan -accept_eula -alwaysPull -assignPremiumPlan -auth NavUserPassword -doNotExportObjectsToText -enableSymbolLoading -imageName microsoft/bcsandbox -includeCSide -memoryLimit 3G -shortcuts Desktop -updateHosts

Get-Command -Module NavContainerHelper
Export-NavContainerObject -containerName devcontainer -objectsFolder c:\myfolder -filter 'Type=Report;Id=206'
Convert-Txt2Al -containerName devcontainer -myDeltaFolder c:\myfolder -myAlFolder c:\myfolder\al -startId 70140931

Git Basics

Standard GIT Process
creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

ORIGIN -> is the default link to the remote repository created when it is cloned.
MASTER -> is the default branch created to work within a repository
HEAD -> is a pointer to the currently checkedout branch

1. When a repository is forked basically a copy for the same is added to your GitHub account.
2. Clone the forked repository to your local directory using git clone command (You have to clone your forked repository, not the original.)
3. Git would automatically add a git remote named origin to the clone of the repository. Use commit to to add commits locally, and use git push to push the changes to the remote git
4. You could additionally will have to add a separate git remote (Git remote would point to the original project repository on GitHub and not the fork) to push the changes using the git remote command
e.g. git remote add alfazane

5. Generally git push will fail unless you have been explicitly granted permission to push changes. Mostly you will be required to work on a branch and then submit a push request to merge your code on the original git. Generally a branch is created for each feature being worked on and will involve the following process
5.1 Create and checkout a feature branch.
e.g: git checkout -b
5.2 Make changes to the files.
5.3 Commit your changes to the branch.
git add and git commit
Also be aware that some projects don’t want a bunch of commits in a pull request, so you may need to use git rebase to “squash the commit history”.
6. Pushing the changes back. Assuming that you are working on a branch called newfeature on the origin remote, the command would be :
git push origin new-feature
7. Start a pull request to the maintainers of the repository to merge the changes if they approve of it.
8. Cleaning up after your changes have been merged by the moderators.
8.1  First, you should update your local clone by using
git pull alfazance master.
8.2 As your feature has been merged you can delete the feature branch :
git branch -d santosh
8.3 Update the master branch in your forked repository to reflect the deletion of the branch done in the step above:
git push origin master

And that’s it! You’ve just successfully created a feature branch, made some changes, committed those changes to your repository, pushed them to GitHub, opened a pull request, had your changes merged by the maintainers, and then cleaned up

Git Stash
Stash a process of parking all the changes done in a branch without actually commiting them. These changes can later be recalled and applied using the git stash apply or pop command.
The stash command will only apply to files that are being tracked and hence a git add would be required before a stash is done for any new files

each stash pushes a stash entry onto a heap. The heap can be viewed using
git stash list
Git stash apply can be used to apply the most recent stash onto the current branch. Applying the stash does not pop it from the heap to apply and pop use
git stash pop
A comment can be saved with a stash
git stash save "added a yellow line"

Keeping Your Fork in Sync
Your forked repository doesn’t automatically stay in sync with the original repository; you need to take care of this yourself.
After all, in a healthy open source project, multiple contributors are forking the repository, cloning it, creating feature branches, committing changes, and submitting pull requests.

To keep your fork in sync with the original repository, use these commands:

git pull alfazance master
git push origin master

This pulls the changes from the original repository (the one pointed to by the alfazance Git remote) and pushes them to your forked repository (the one pointed to by the origin remote).
We can also use
git fetch origin
to fetch the changes locally however these changes are not merged and will have to be merged manually using
git merge origin/master
to combine git fetch and merge the git pull command can be used.

Clean up a fork and restart it from the upstream
git remote add upstream /url/to/original/repo
git fetch upstream
git checkout master
git reset --hard upstream/master 
git push origin master --force

Discard local changes
git checkout --  

1. start git bash, if you want to clone a copy of some other users folder first clone it on Once cloned you will get a link created for that fork into you account. This link would be used in next step

2. clone the folder from
git clone

3. Staging is a process where a copy of the file is marked for commit. The changes are staged using a git add command.
git add

4. Once the changes are queued commit the changes
git commit -m "your description of changes"

5. Commiting all the tracked files without a need for staging can be done using -a switch
git commit -a -m "commit description"

5. List of the changes staged for commit
git log

6. Branching: created for working on a work stream
git branch

7. switch to a branch
git checkout

8. Merge a branch into another branch. First checkout the destination branch and then use the following command
git merge

9. stash : Its a process of parking all the changes done in a branch without actually commiting them. The stash command will only apply to files that are being tracked and hence a git add would be required before a stash is done for any new files
git stash

10. recall stash :
git stash apply

11. remote repositories: when multiple collaborators are working on the same repository they each can create a copy of their own. One can view the list of all the remote copies for the currently selected git as follows

get a list of all the remote repositories with their online urls
git -remote -v

to maintain a version of the repository a new repository can be added as follows
git remote -add  
$ git remote -add pb
$ git remote rename pb paul
$ git remote remove paul

when pushing or pull the changes a contributor can select which copy he/she would like to use.
$ git fetch
$ git push origin master

12. fetch is a process of getting the remote changes without merging them into the local folders.
git fetch origin

13. pull is the process of fetching the changes and merging them into the local folder
git pull origin

14. push is the process of pushing the committed changes to the remote reporsitory and branch
git push
git push origin master

7. To get a list of pending changes
git status

8. To push the local commits to
git push --all

9. To stash local changes and get server copy
git pull --autostash --rebase

10. Revert a commit pushed to the server
git revert {commit_id}

1. HEAD refers to the changes in the current branch

2. When prompted for message
press "i"
write your merge message.
press "esc"
write ":wq"
then press enter.

3. Create a file not possible using windows explorer (eg. a filename starting with period(.))

4. To see a history of commits
git log --oneline --decorate --graph --all

5. Edit the .gitignore file
That can be done using the vim editor.
Simply type vi [path-to-file]\file and you will open the vim terminal editor.
Press a to toggle the edit mode
Edit stuff
Press Esc to finish edit mode and toggle the command mode
Press/type : to indicate you want to type a command
Type and enter wq to save the changes and exit

If you want to delete all your commit history but keep the code in its current state, it is very safe to do it as in the following:

git checkout --orphan latest_branch

Add all the files
git add -A

Commit the changes
git commit -am "commit message"

Delete the branch
git branch -D master

Rename the current branch to master
git branch -m master

Finally, force update your repository
git push -f origin master

PS: this will not keep your old commit history around

Wednesday, September 19, 2018

Outlook Duplicate Calendar Entries

use the following command to reset the calendar pane

outlook.exe /resetnavpane