Recently just set up a docker to work under windows behind a corporate firewall
Prerequisite:
- Enable VT-X in BIOS
- Setup Server environment variable in the host PC
HTTP_PROXY=http://<proxy>:<port>
HTTPS_PROXY=http://<proxy>:<port>
NO_PROXY=192.168.99.100
1. Download docker toolbox for windows and install it
2. Start Docker quick terminal
I removed the default image and recreate one.
docker-machine stop default
docker-machine rm default
3. Create a image named dev
docker-machine create --driver virtualbox dev
4. Set up the start environment variable
docker-machine env dev
eval $("C:\program files\docker toolbox\docker-machine.exe" env dev)
docker ps
5.Remote SSH to the image and set up proxy in it
docker-machine ssh dev
sudo -s
echo "export HTTP_PROXY=http://<proxy>:<port>" >> /var/lib/boot2docker/profile
echo "export HTTPS_PROXY=http://<proxy>:<port>" >> /var/lib/boot2docker/profile
cat /var/lib/boot2docker/profile
exit
6. Restart the image
docker-machine restart dev
7. Run hello-world to test
docker run hello-world
-----
There are also a few useful command to use
docker ps -a
docker run -p 3000:3000 -v $(pwd):/var/www -w /var/www node npm start
-----------
Updated, just found a blog talking about this as well.
http://www.netinstructions.com/how-to-install-docker-on-windows-behind-a-proxy/
Monday, May 23, 2016
Friday, April 1, 2016
Tangling with Git proxy settings in windows
To set up git proxy globally, you need to run this command
git config --global http.proxy "http://<your proxy>:<port>"
However, it returned me error,
1. echo %userprofile%
2. create a new environment variable as HOME = the user profile directory
And then you can run the config http.proxy command.
git config --global http.proxy "http://<your proxy>:<port>"
However, it returned me error,
error: could not lock config file H:\/.gitconfig: No such file or
directory error: could not lock config file
To fix it, need to set up the %HOME% environment variable to your user profile path1. echo %userprofile%
2. create a new environment variable as HOME = the user profile directory
And then you can run the config http.proxy command.
Friday, February 12, 2016
Setting up Github with Visual Studio Code
Visual studio code support work with GitHub, you can reference the below link for the detailed steps,
http://michaelcrump.net/using-github-with-visualstudio-code/
The main command is the below to run in a command shell,
Then the config file in the .git folder will become as below,
git config --global credential.helper wincred
git config --global user.name "YOUR NAME"
http://michaelcrump.net/using-github-with-visualstudio-code/
The main command is the below to run in a command shell,
git remote add origin https://github.com/xinzhang/SampleProject.git
git push -u origin master
[remote "origin"]
url = https://github.com/mbcrump/SampleProject.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
After this is done, you commit the changes but there is still the below commands to run to be able to run PUSH from Visual Studio Code,git config --global credential.helper wincred
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL ADDRESS"
Thursday, May 21, 2015
Get Ionic framework working behind proxy
I have the error to create a new ionic project when running the command in windows 7
ionic start myproject
The solution is to set up the MAGIC environment variable in the computer settings, then it works.
ionic start myproject
The solution is to set up the MAGIC environment variable in the computer settings, then it works.
http_proxy=http://username:password@hostname:port;
Wednesday, May 6, 2015
Error to download bower package in Visual studio 2015 RC when you are in corporate proxy
1. add a .bowerrc file in project,
{
"proxy": "http://192.168.11.22:8080",
"https-proxy":"http://192.168.11.22:8080"
}
2. Install Git seperately
3. go to command prompt and run the following cmd
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
git config --global https.proxy https://proxyuser:proxypwd@proxy.server.com:8080
{
"proxy": "http://192.168.11.22:8080",
"https-proxy":"http://192.168.11.22:8080"
}
2. Install Git seperately
3. go to command prompt and run the following cmd
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
git config --global https.proxy https://proxyuser:proxypwd@proxy.server.com:8080
Tuesday, May 5, 2015
Error to download npm package in Visual studio 2015 when you are in corporate proxy
This is the command to run to set up the proxy,
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
But where to run this command, the npm.cmd is in,
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External
Open a command prompt as administrator and run the npm config ...
Then it worked.
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
But where to run this command, the npm.cmd is in,
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External
Open a command prompt as administrator and run the npm config ...
Then it worked.
Custom asp.net identity 2.1 tables and primary keys
This is the codes that I use to set up the identity tables to use int as primary key.
public class User : IdentityUser<int, UserLogin, UserRole, UserClaim>
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<User, int> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
public string FirstName { get; set; }
public string LastName { get; set; }
public byte Level { get; set; }
public DateTime JoinDate { get; set; }
}
public class UserRole : IdentityUserRole<int> { }
public class UserLogin : IdentityUserLogin<int> { }
public class UserClaim : IdentityUserClaim<int> { }
public class Role : IdentityRole<int, UserRole>
{
public Role() { }
public Role(string name) { Name = name; }
}
public class MyUserStore : UserStore<User, Role, int, UserLogin, UserRole, UserClaim>
{
public MyUserStore(MyPortalContext context)
: base(context) { }
}
public class MyRoleStore : RoleStore<Role, int, UserRole>
{
public MyRoleStore(MyPortalContext context)
: base(context) { }
}
/////////////////////////////////////////////////////////
And they are customized to use different table names in MyPortalContext
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>().ToTable("Users");
modelBuilder.Entity<Role>().ToTable("Roles");
modelBuilder.Entity<UserLogin>().ToTable("UserLogins");
modelBuilder.Entity<UserClaim>().ToTable("UserClaims");
modelBuilder.Entity<UserRole>().ToTable("UserRoles");
}
public class User : IdentityUser<int, UserLogin, UserRole, UserClaim>
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<User, int> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
public string FirstName { get; set; }
public string LastName { get; set; }
public byte Level { get; set; }
public DateTime JoinDate { get; set; }
}
public class UserRole : IdentityUserRole<int> { }
public class UserLogin : IdentityUserLogin<int> { }
public class UserClaim : IdentityUserClaim<int> { }
public class Role : IdentityRole<int, UserRole>
{
public Role() { }
public Role(string name) { Name = name; }
}
public class MyUserStore : UserStore<User, Role, int, UserLogin, UserRole, UserClaim>
{
public MyUserStore(MyPortalContext context)
: base(context) { }
}
public class MyRoleStore : RoleStore<Role, int, UserRole>
{
public MyRoleStore(MyPortalContext context)
: base(context) { }
}
/////////////////////////////////////////////////////////
And they are customized to use different table names in MyPortalContext
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>().ToTable("Users");
modelBuilder.Entity<Role>().ToTable("Roles");
modelBuilder.Entity<UserLogin>().ToTable("UserLogins");
modelBuilder.Entity<UserClaim>().ToTable("UserClaims");
modelBuilder.Entity<UserRole>().ToTable("UserRoles");
}
Subscribe to:
Posts (Atom)